【发布时间】:2018-10-23 05:44:49
【问题描述】:
在 WordPress 侧边栏上列出子页面需要帮助,我已经创建了带有特征图像的子页面及其仅显示的列表 wp_list_pages,但我不知道如何要在 WordPress 侧边栏上显示带有 wp_list_pages 的子页面缩略图,我找不到合适的示例来说明如何使用代码来执行此操作。请帮帮我
下面是我的代码:
<?php
$ancestor_id = 1594;
$descendants = get_pages( array( 'child_of' => $ancestor_id ) );
$incl = '';
foreach ( $descendants as $page ) {
if ( ( $page->post_parent == $ancestor_id )
|| ( $page->post_parent == $post->post_parent )
|| ( $page->post_parent == $post->ID )
) {
$incl .= $page->ID . ",";
}
}
?>
<ul>
<?php
wp_list_pages( array(
'child_of' => $ancestor_id,
'include' => $incl,
'link_before' => '',
'title_li' => '',
'sort_column' => 'menu_order'
) );
?>
</ul>
【问题讨论】:
标签: php wordpress function sidebar children