Support » Themes and Templates » List subpages in WordPress navigation menu

  • Resolved befree22



    I’ve read and

    I’d like to list subpages in the navigation menu in header.php for the Photos page. My current navigation menu code at is

    <?php wp_list_pages('title_li=&depth=1&sort_column=menu_order&exclude=69,75,84'); ?>

    I’ve tried adding the following code to header.php to list subpages for the top navigation menu at but it’s not working properly. I want to exclude the 3 pages listed in the above code.

      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <?php echo $children; ?>
      <?php } ?>

    Could someone help me find the correct code so that I exclude exclude=69,75,84 from the navigation menu top pages and subpages?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Here’s the full code for the current header.php filej

    [57 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]



    Forum Moderator

    I’m sorry but as you are using a commercial theme, you need to seek support from the theme’s vendors.

    To: Moderator

    I downloaded this theme for free a month ago. Their support forum isn’t accepting new members. Thanks anyway.

    Sorry, I can’t help you with this. Try searching for a plugin:

    I’m using this 2012 child theme at this site and I have the latest WordPress update. I want to hardcode the top navigation menu links in header.php because the top nav menu keeps displaying ALL pages on the site whenever I make changes to the custom css. I added the menu pages in WP admin > Menu > Theme locations. I’m only using the top menu and the footer menu. The child theme came with the top menu and the lower menu (below the top menu) but I added the footer menu code from WP Codex.

    The code I added is this …

    </nav><!-- #site-navigation -->
    <?php wp_list_pages('title_li=&depth=1&sort_column=menu_order&exclude=497,10,21,24,15,43,295,500,13'); ?>

    …but it’s not registering on the site yet. Is this code correct and I’m I adding it to the right spot in the header.php? The complete header.php code is

    <?php wp_list_pages('include=497,10,21,24,15,43,295,500,13&title_li=&depth=1&exclude=69,75'); ?>

    I’m trying the code above but it’s still not registering. Two pages that I want to exclude from the top nav menu are Pages and Thank You. The Credits page should be listed before the Contact page. The page id’s show the sort order for the pages. What am I missing?

    The pages are all sorted in WP admin > Menu > Theme locations several days ago.

    Can you send me a link to the site so I can see what might be the root of the problem?

    It’s here.

    WP admin interface permits you to specify the order in the WP admin > Appearance > Theme locations but I’m thinking that I also have to specify the order by editing the page details, ie. Pages > Page attributes which I’m working on.

    Still, I want to exclude the 2 pages mentioned above.

    Have you created the menus in the Menu section of the appearance tab or is the menu written directly in a php file? You should try the standard method of using wordpress menus before resorting to something complex.

    How to include a menu

    I’m quite familiar using WP admin to add menus via WP admin > Menus > Theme location (see thread above). My issue is that ALL pages, and not just pages added to the top menu, are displaying on the site, namely the Privacy and Thank you pages.

    If you viewed the site, you’ll see those 2 pages are included in the top menu but they don’t appear in the WP admin > Menu > Theme location for the top/primary menu. This is why I wanted to resort to hardcoding the menu in the header.php.

    The related issue is that whenever I add this code to exclude the 2 pages from the top menu, I get a list of ALL pages displaying belowing the top menu:

    <?php wp_list_pages('exclude=69,75' ); ?>

    I’m having the author of this 2012 child theme look into this issue.

    Fixed by author. Although I had set the Primary Menu in WP Admin > Appearance, I forgot to uncheck the “Add top level menus automatically” in the menu options. Now the 2 pages aren’t displaying in the Primary/Top menu.

    Thanks for your time.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘List subpages in WordPress navigation menu’ is closed to new replies.