【发布时间】:2017-07-21 17:47:46
【问题描述】:
我有这个模板来显示所有的新闻页面,它们都是 news_all 页面的子页面。 在 news_all 页面的模板里面有如下代码。
部分模板get-news-template.php:
<?php $the_query = new WP_Query(array(
'post_type' => 'page',
'post_parent' => 143
));
while ($the_query->have_posts())
{
$the_query->the_post();
echo get_the_title();
}
wp_reset_postdata();
?>
其中 143 是 news_all 页面的 id。 由于某种原因,这不起作用,我是否以错误的方式使用它?请帮忙。
我的最终目标是迭代并将所有新闻页面显示为侧边栏中的列表。
编辑:添加了 post_type,但仍然没有,此页面至少有两个子页面,它们应该得到回显,对吗?
【问题讨论】: