Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义元框在博客页面上不起作用_Php_Wordpress - Fatal编程技术网

Php 自定义元框在博客页面上不起作用

Php 自定义元框在博客页面上不起作用,php,wordpress,Php,Wordpress,欢迎光临,我从中创建了自定义元框,但如果我在WordPress中设置 Page of entries>Blog-Page 我的$my_meta['name']和$my_meta['description']]是从上一个博客条目中获取的,而不是从我的自定义元框中获取的;/ 我应该怎么做才能从博客页面上的自定义元框中获取名称和描述?在另一页上,它工作得很好,谢谢你的回答我认为你需要功能。它从指定的post返回具有指定键的自定义字段的值 //Inside your Blog page Loop. 'm

欢迎光临,我从中创建了自定义元框,但如果我在WordPress中设置

Page of entries>Blog-Page

我的
$my_meta['name']
$my_meta['description']]
是从上一个博客条目中获取的,而不是从我的自定义元框中获取的;/

我应该怎么做才能从博客页面上的自定义元框中获取名称和描述?在另一页上,它工作得很好,谢谢你的回答

我认为你需要功能。它从指定的post返回具有指定键的自定义字段的值

//Inside your Blog page Loop. 'meta_key' is the key of your custom field. Do the same for each custom field. Please take a look in the Codex  from the above link.
echo get_post_meta( get_the_ID(), 'meta_key', true );
我可能错了,因为这个问题没有其他线索


希望有帮助

这将获取页面的ID,而不是最后一篇文章(对于设置->阅读中设置为“文章”页面的页面):

//get page id even for posts page
global $wp_query;
$page_id = $wp_query->get_queried_object_id();