我意识到Wordpress的问题很难回答,因为有太多的插件和复杂的问题。
我们在Wordpress页面上遇到了一些问题,虚拟页面将用所有没有显式父级(父级:(无父级))的页面填充其子菜单。
我已将有问题的代码隔离到标题中的这段代码中:
<!-- Secondary Nav -->
<!-- Show Secondary Menu if the page is a child or has children -->
<?php global $post; $children = get_pages( array( \'child_of\' => $post->ID ) );
if ( is_page() && $post->post_parent || count( $children ) > 0 ) : ?>
<div class="row subnav">
<div class="container">
<div class="columns large-12">
<ul>
<?php wp_list_pages( array(\'title_li\'=>\'\',\'depth\'=>1,\'child_of\'=>get_post_top_ancestor_id()) ); ?>
</ul>
</div>
</div>
</div>
<?php else : ?>
<!--This is a parent page without children -->
<?php endif; ?>
研究表明,虚拟页面通常是有子页面的页面,而不是没有子页面的页面。Wordpress如何处理与页面相关的虚拟页面。。。孩子?正如在普通页面上所期望的那样,它会得到一个附属菜单项的列表。
我在buddypress上也看到过同样的行为,而coursepress现在也出现了这种情况。
我想更重要的是,在if语句中有没有一种方法可以将虚拟页面与普通页面分开,这样就不会为它们生成子菜单?
以下是几个图像示例: