【发布时间】:2016-04-15 07:22:23
【问题描述】:
我有这个循环,我需要显示具有特定元值的帖子的所有标题,或者没有元键“the_status”。
我的帖子目前使用名为“the_status”的元键,并且可以具有以下任一元键值:
帮助 not_helping 完成_帮助
...或者帖子甚至可能根本没有 meta_key 'the_status'。
这是我所拥有的:
<?php
$the_query = array(
'posts_per_page' => -1,
'author' => $current_user->ID,
'post_status' => 'publish',
'meta_key' => 'the_status',
'meta_value' => array('helping')
);
$help_posts = new WP_Query($the_query);
while($help_posts->have_posts()) : $help_posts->the_post();
?>
<p><?php the_title(); ?></p>
<?php
endwhile;
?>
这显然只给了我带有 meta_value 'helping' 的帖子的标题,但它还需要显示根本没有 meta_key 'the_status' 的帖子的标题。
感谢阅读。
【问题讨论】:
标签: arrays wordpress loops meta-key