我试图列出特定ID的页面,但希望在列表中包括父页面
<?php
$parent = 83;
wp_list_pages( array(
\'title_li\' => \'\',
\'child_of\' => $parent,
) );
?>
我尝试添加\'include\' => 83
但它只列出了父母,没有列出孩子。我试图列出特定ID的页面,但希望在列表中包括父页面
<?php
$parent = 83;
wp_list_pages( array(
\'title_li\' => \'\',
\'child_of\' => $parent,
) );
?>
我尝试添加\'include\' => 83
但它只列出了父母,没有列出孩子。您可以使用wp\\u get\\u post\\u parent\\u id(get\\u the\\u id())获取父对象,并将其存储在一个新变量中,然后对子对象执行相同的操作,然后以您想要的任何格式显示它们。
<?php
$theParent = wp_get_post_parent_id(get_the_ID());
if ( $theParent->ID == 83 ) { ?>
<div class="parent"><?PHP echo get_the_title($theParent); ?></div>
<ul class="children"><?PHP wp_list_pages(array(
\'title_li\' => \'\',
\'child_of\' => $theParent ?> </ul>
<?PHP } ?>
希望这会有所帮助wordpress中缺少所有已发布的页面。他们仍然在我的网站(chrisjscambler.com)上在线,例如,我的家、研究和教学都在网上活跃;但它们无法在wordpress中编辑。直到最近,他们都在那里!有什么建议吗?