Reputation: 9
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; 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>
Upvotes: 0
Views: 94
Reputation: 1345
Replace your first line with the following code. Update 12 with the IDs of your child pages that you want to exclude.
Note: I moved the parameters into $args as its easier to read and maintain,
$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().
Upvotes: 0