[英]How to remove specific children pages when using echo $children; in Wordpress
UPDATE: Fixed it!! 更新:修复它!
<?php
$children = wp_list_pages("title_li=&child_of=".$root_parent_id."&sort_column=menu_order&echo=0&exclude=912");
if ($children) {
?>
We are using the following php code in the page.php file to dynamically build our sidebar nav section; 我们在page.php文件中使用以下php代码动态构建我们的侧边栏导航部分; however, I need to exclude certain child pages from appearing. 但是,我需要排除某些子页面的出现。 Any suggestions would be very helpful! 任何建议将非常有帮助!
<?php
$children = wp_list_pages("title_li=&child_of=".$root_parent_id."&sort_column=menu_order&echo=0");
if ($children) {
?>
<div class="submenu">
<h2><?php echo get_the_title( $root_parent_id ); ?></h2>
<ul>
<?php echo $children; ?>
</ul>
</div>
Replace your first line with the following code. 用以下代码替换第一行。 Update 12 with the IDs of your child pages that you want to exclude. 使用要排除的子页面的ID更新12。
Note: I moved the parameters into $args as its easier to read and maintain, 注意:我将参数移到$ args中,因为它更易于阅读和维护,
$args = array(
'title_li' => '',
'child_of' => $root_parent_id,
'sort_column' => 'menu_order',
'echo' => 0,
'exclude' => '12'
);
$children = wp_list_pages($args);
Here is more info on wp_list_page() . 这是有关wp_list_page()的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.