Php 列出一个孩子';Wordpress中的同级页面

Php 列出一个孩子';Wordpress中的同级页面,php,wordpress,Php,Wordpress,我正在为一家酒店建立一个网站,在我的侧边栏文件中,我有一个PHP脚本来打印子页面列表。结构如下: 餐厅(早餐、午餐、晚餐) 客房(标准间、双人房、豪华房) 因此,本质上,当用户位于父页面(餐厅或房间)或子页面时,我希望在侧边栏中显示子页面(括号中的那些页面) 但是,我的脚本似乎不起作用,也不显示页面列表 //SET UP FAMILY $children = get_pages('child_of='.$post->ID); $parent = $post->po

我正在为一家酒店建立一个网站,在我的侧边栏文件中,我有一个PHP脚本来打印子页面列表。结构如下:

  • 餐厅(早餐、午餐、晚餐)

  • 客房(标准间、双人房、豪华房)

因此,本质上,当用户位于父页面(餐厅或房间)或子页面时,我希望在侧边栏中显示子页面(括号中的那些页面)

但是,我的脚本似乎不起作用,也不显示页面列表

//SET UP FAMILY
    $children = get_pages('child_of='.$post->ID);
    $parent = $post->post_parent;
    $siblings = get_pages('child_of='.$parent);

    if(count($children) != 0 ) {
        $args = array(
            'depth' => 1,
            'title_li' => null,
            'sort_column' => 'menu_order',
            'child_of' => $post->ID
        );
    }

    else if($parent != 0) {
        $args = array(
            'depth' => 1,
            'title_li' => null,
            'sort_column' => 'menu_order',
            'exclude' => $post->ID,
            'child_of' => $parent
        );
    }

    if(count($siblings) > 1 && !is_null($args)) {
        echo "<ul class='pages'>";
        echo "<h2>Browse</h2>";
        wp_list_pages($args);
        echo "</ul>";
    }
//设置族
$children=get\u页面('children\u of='。$post->ID);
$parent=$post->post\u parent;
$SISTERS=获取页面('child\u of='。$parent);
如果(计数($children)!=0){
$args=数组(
“深度”=>1,
“title_li”=>空,
“排序列”=>“菜单顺序”,
'child_of'=>$post->ID
);
}
如果($parent!=0),则为else{
$args=数组(
“深度”=>1,
“title_li”=>空,
“排序列”=>“菜单顺序”,
“排除”=>$post->ID,
“=>父项的子项”
);
}
如果(计数($同级)>1&&!为空($args)){
回声“
    ”; 回应“浏览”; wp_列表_页面($args); 回声“
”; }
我不介意当前页面是否显示在菜单中