0
我想通过id获取帖子。 Id的数组。我正在使用此代码,但现在正在工作。通过id在wordpress中获得帖子
$the_query = new WP_Query(array(
'post_type' => 'job_listing',
'post__in' => array(311, 312)
));
print_r($the_query); //this doesn't print any data
if ($the_query->have_posts()) {
echo '<ul>';
while ($the_query->have_posts()) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
}
那么,当运行时没有任何显示? – Howli
'print_r($ the_query);'不打印**事实**真的很奇怪......你是否在你的代码中使用了命名空间? – MikO
已经做到了,谢谢你的时间 – Riz