Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For example, I'm using wp_list_pages to display the navigation, the child pages (and their children) appearing on hover as is typical. However, I want one of these parents to not display the children. Essentially I want something like exclude_children_of to work in the wp_list_pages arguments; is there a way of doing this anybody?

thanks

Rob

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

try -:

if your page ID = 999

<?php
$child_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 999  AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
$exclude = implode($child_ids,', ');
wp_list_pages('exclude=' . $exclude . '&title_li=<h2>' . __('Pages') . '</h2>');
?>
share|improve this answer
    
Fantastic, thanks very much! –  Rob Dobson May 30 '12 at 12:49
    
you are most welcome. –  krembo99 May 30 '12 at 13:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.