Support » How-To and Troubleshooting » [Resolved] Excluding Child Pages from Menu Listing

[Resolved] Excluding Child Pages from Menu Listing

  • I’ve setup a menu listing using wp_list_pages(). The menu has child pages on two of the menu items. But the client has now asked for the child pages of one of these to be removed from the menu. Is there a way to achieve this using wp_list_pages or should I be using another function. I’d originally removed it using the PageMash plugin but unfortunately it removes it from everywhere and I need the listing to appear on a particular page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You should be able to use the exclude parameter.


    Thanks, sort of works for the moment. But the client will be adding more child pages themselves and they are not going to be able to, know how to or want to edit the function with additional id numbers. Now if there was a parameter that said ‘exclude_child_of’, then that would be great.

    Did you see the exclude_tree=x,y,z argument that template tag, wp_list_pages(), provides?

    This is no good as it excludes the parent as well as the children. I only want to exclude the children.

    Will the depth=1 argument work? If not it likely means manually keeping your exclude or include list updated or using Function_Reference/get_pages to determine those child ids you want excluded then use that list with wp_list_pages.

    $parent = 93;
      'child_of' => $parent
    $pages = get_pages($args);
    if ($pages) {
      $pageids = array();
      foreach ($pages as $page) {
        $pageids[]= $page->ID;
        'title_li' => 'All but children of Parent Page ' . $parent,
        'exclude' =>  implode(",", $pageids)

    Thanks last solution does the trick. Depth parameter sets for all not just one.

    Many thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Excluding Child Pages from Menu Listing’ is closed to new replies.