我正在使用wp_list_pages()
显示子页面菜单。
结构简单美观。如下所示:http://cl.ly/image/0w1Q1q2D3D18
在子页面上时,菜单工作正常:http://cl.ly/image/3O310E0s2B3d
但是,唉,在父页面上时不起作用:http://cl.ly/image/3w0T3Q2s4347
看起来很简单,但我就是不知道到底是怎么回事。
这是我的wp_list_pages()
代码:
<?php
$topmost_parent = $post->post_parent;
$args = array(
\'post_type\' => \'guides\',
\'sort_column\' => \'menu_order\',
\'title_li\' => __(\'\'),
\'echo\' => 0,
\'exclude\' => $topmost_parent
);
$children = wp_list_pages( $args );
if ($children) :
?>
<nav id="menu-context">
<ul class="menu">
<?php echo $children; ?>
</ul>
</nav>
<?php endif;?>
使用该$topmost_parent
直到我出现在父页面上,这个技巧才奏效。有人有新把戏吗?=)