Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Unable to exclude page from navigation (18 posts)

Started 2 years ago by: absticles

  • Profile picture of absticles absticles said 2 years ago:

    Hey there.

    I can’t seem to exclude certain pages from the main navigation. The links are listed using the wp_list_pages template tag and the parameters are ‘title_li=&depth=1&exclude=14′.

    14 being the page ID of the page I wish to exclude. For some reason it’s still sitting in the navigation.

    I’ve also tried excluding it using the page widget in the Appearance settings.

    Hope someone can help!

    Thanks,
    Abi

  • Profile picture of absticles absticles said 2 years ago:

    Can anyone help with this? Thanks. Abi

  • Profile picture of r-a-y r-a-y said 2 years ago:

    If you’re using a child theme, simply edit header.php and modify the wp_list_pages() line with:

    wp_list_pages( 'exclude=14' );

  • Profile picture of absticles absticles said 2 years ago:

    I did actually try this and it still doesn’t hide it! And I tried it in the page widget in the Appearance settings!

    Hope you can help. Thanks. Abi

  • Profile picture of @mercime @mercime said 2 years ago:

    What @r-a-y gave you works for me in bp-default child theme. What theme are you using? Do you have any plugin relating to navigation or pages installed in your WP?

  • Profile picture of absticles absticles said 2 years ago:

    Yep I’m using a child theme. It’s bizarre that it doesn’t work.

    I have the following plugins activated:
    ‘Buddypress’
    ‘Remove BuddyPress Admin Bar’

    They’re the only ones activated!

  • Profile picture of r-a-y r-a-y said 2 years ago:

    Make sure that you’re referencing the right page ID? Also try other page IDs to see if wp_list_pages() is actually working.

  • Profile picture of absticles absticles said 2 years ago:

    Tried hiding a page with a different ID using:
    title_li=&depth=1&exclude=2

    Still doesn’t hide!

  • Profile picture of absticles absticles said 2 years ago:

    Does any one have any ideas? Driving me nuts! Thanks, Abi

  • Profile picture of Boone Gorges Boone Gorges said 2 years ago:

    The code that people are giving should work. The only way we could test any further is if you posted the code you’re trying to use in context. Are you using a common theme, or one you developed yourself? If the latter, can you put the contents of header.php into a pastebin so others can test it?

  • Profile picture of absticles absticles said 2 years ago:

    I am creating a buddypress child theme.

    http://tinypaste.com/64e4b

    wp_list_pages should be on line 91. All of that code is within my header.php file.

    Thanks,
    Abi

  • Profile picture of r-a-y r-a-y said 2 years ago:

    You have to add a comma, see below:
    exclude=2,'. bp_dtheme_page_on_front()

  • Profile picture of absticles absticles said 2 years ago:

    Ah. As simple as that! Genius. Thanks r-a-y!

  • Profile picture of Arx Poetica Arx Poetica said 1 year, 10 months ago:

    Adding to this thread (maybe I should start a new?)…suppose I didn’t want to edit header.php in any way shape or form. Is there any way to suppress certain pages from a functions.php page…

    …further what I might actually want to do is suppress *all* wp_list_pages() and just keep the native BuddyPress ones. Hmm…any thoughts?

  • Profile picture of r-a-y r-a-y said 1 year, 10 months ago:

    @arxpoetica – That’s possible via the “wp_list_pages_excludes” filter.

    You’ll need to return an array of page IDs you want to exclude.

    Example code:

    http://pastebin.com/HUyVsWSN

    Change 1,2,3 to page ids you want to omit.