WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Excluding pages from nav menu (8 posts)

  1. bearing
    Member
    Posted 4 years ago #

    I need to remove a link to a page on my nav menu, but I don't want it to disappear from the Page menu in the sidebar.

    I've tried the 'Exclude Pages' plug-in by Simon Wheatley but this removes the page from both menus, is there a way to remove it from only the nav menu at the top whilst leaving the link in the Pages menu?

  2. Samuel B
    moderator
    Posted 4 years ago #

    you will need to edit the theme's header.php and use the "exclude" code in the navbar section - look for this

    <?php wp_list_pages('title_li=&depth=1'); ?>
    change to this
    <?php wp_list_pages('title_li=&depth=1&exclude=45'); ?>

    where "45" is your page id to exclude

  3. bearing
    Member
    Posted 4 years ago #

    Cheers for that I'll give it a try this evening.

  4. bearing
    Member
    Posted 4 years ago #

    Just had a quick look, I have this:

    <?php wp_list_pages('title_li=&parent=0&'); ?>

    should I change this to

    <?php wp_list_pages('title_li=&parent=0&exclude=xx'); ?>

    xx being the page id.

  5. Samuel B
    moderator
    Posted 4 years ago #

    yes - that will work

  6. bearing
    Member
    Posted 4 years ago #

    Thanks and it does indeed work.

  7. newtrouble
    Member
    Posted 4 years ago #

    I made another page my static home page - and it shows up on all navigation bars twice - as the home page and the static page. Any help on excluding or hiding one or the other? There is no page id assigned to it as it's the home page.

    Thanks for any help.

  8. La M
    Member
    Posted 4 years ago #

    I need to do the same thing, but I don't have this <?php wp_list_pages?> line in my header.php.

    I have a couple of legal pages that I don't want listed in my top horizontal menu.

    I think the relevant code is:

      <?php if (get_option('ap_includeHome') == 0){ ?>
      <li class="<?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>">/"><?php _e('Home') ; ?>
      <?php } ?>
      <?php ap_buildMenu(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic