WordPress.org

Ready to get started?Download WordPress

Forums

Exclude Page From Menu (5 posts)

  1. ritalmclelland01
    Member
    Posted 1 year ago #

    Trying to exclude page from Nav menu but can't seem to get all the pages to remove. Here is my code:

    <?php wp_nav_menu( array( 'container_class' => 'menu-header','exclude'=>100,'exclude'=>228,'exclude'=>259, 'theme_location' => 'primary' ) ); ?>

    Using this code it will exclude 100 and 259 but 228 keeps showing on the menu can someone please tell me what I am doing wrong.

    Thanks in advance

  2. Zulfikar Nore
    Member
    Posted 1 year ago #

    Try using this code.
    <?php wp_nav_menu( array( 'container_class' => 'menu-header','exclude=100,228,259', 'theme_location' => 'primary' ) ); ?>

    A better way of doing this would be to use the custom menu under the Appearance>>Menus if your theme supports it.

  3. ritalmclelland01
    Member
    Posted 1 year ago #

    Thanks but that does not work either now the only pageid that is not showing is 100 the other 2 now show on nav menu.

    This was a custom designed site so somewhat afraid to use the custom menu function for fear it may damage the entire site if it does not fit within the area properly.

  4. Techno Tim
    Member
    Posted 1 year ago #

    With creating a custom menu you can select which is your primary menu, so I cannot see how you can break it, if it does not work switch it back.

  5. Techno Tim
    Member
    Posted 1 year ago #

    Another way is to make the page private under Publish visability on the page editor, you can still link to these pages manually, I use this for footer links, and other content pages that I do not want in the main menu.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.