【发布时间】:2021-04-07 02:49:16
【问题描述】:
我将下面的代码放在一个帖子页面中。
问题是它显示当前帖子的正确标题但计数不正确。
当实际计数为 1 时,它显示计数 0。
当前帖子已购买=yes 且 firstsubmission=yest,因此应显示 1。
我使用 'post_parent' => get_the_ID(),而不是 'title' => get_the_title() 和 'posts_per_page' => 1,但仍然显示计数 0。
你能帮我更正代码吗?
$info_args = [
'author' => get_current_user_id(),
'title' => get_the_title(),
'posts_per_page' => -1,
'post_type' => 'infosubmission',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'purchased',
'value' => 'yes',
'compare' => '=',
'key' => 'firstsubmission',
'value' => 'yes',
'compare' => '=',
)
)
];
$info_info_posts = get_posts($info_args);
$info_info_count = count($info_info_posts);
echo 'Title: ' . get_the_title() .'<br>';
echo 'Count:' .$info_info_count ;
谢谢。
【问题讨论】: