Php wordpress中的自定义元数据
我在一个单独的页面上获取一篇文章 除了自定义值meta之外,它都可以工作Php wordpress中的自定义元数据,php,wordpress,Php,Wordpress,我在一个单独的页面上获取一篇文章 除了自定义值meta之外,它都可以工作 <?php $the_id = ""; if(get_post_meta(get_the_id(), 'newpostid', 'true')) { $the_id = get_post_meta(get_the_id(), 'newpostid', 'true'); }else if(get_post_meta(get_the_id(), 'oldpostid', 'true')) { $the_
<?php
$the_id = "";
if(get_post_meta(get_the_id(), 'newpostid', 'true')) {
$the_id = get_post_meta(get_the_id(), 'newpostid', 'true');
}else if(get_post_meta(get_the_id(), 'oldpostid', 'true')) {
$the_id = get_post_meta(get_the_id(), 'oldpostid', 'true').''; } ?>
<?php
$post_id = $the_id;
$queried_post = get_post($post_id); ?>
<h2><?php echo $queried_post->post_title; ?></h2>
有人能帮我获取自定义字段值吗
这就是我得到的:
<?php echo $queried_post->get_post_meta(get_the_id(), 'newpostid', 'true'); ?>
但这会导致致命的错误
求救 get\u post\u meta只是一个函数,而不是$queryed\u post的方法 您可以使用这样的构造:
get_post_meta($queried_post->ID, 'newpostid', 'true');
但这与:
get_post_meta($post_id, 'newpostid', 'true');
或
get_post_meta($the_id, 'newpostid', 'true');