WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to exclude pages from horizontal navi in twentyten? (8 posts)

  1. beru82
    Member
    Posted 4 years ago #

    Hi folks,

    I don't want to have the pages "Imprint" & "Disclaimer" shown on my website instead I want them to be only in the footer (managed to do that at least!).

    I tried two plugings that are supposed to exclude pages but they didn't work for me.

    The source code of the header.php looks like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Anybody help?

  2. WPcompass
    Member
    Posted 3 years ago #

    This topic is marked as "resolved"... yet there is nothing other than the original post (and now, this first comment).

    Further (Google) search turned up a solution: http://gravitationalpull.net/wp/?p=1466

    This solution is good for small nav menus, i.e., no child pages. The cool "Menu" administration in WP's dashboard does not appear to accommodate child pages.

    I've poured through the codex documentation, found the WP 2.0 solution on how to exclude pages from the list: http://codex.wordpress.org/Template_Tags/wp_list_pages

    ... but,alas, Twenty Ten does not use the simple wp_list_pages function.

    Any code-savvy samaritan want to chime in with a solution? Is this where the use of filters come into play?

  3. esmi
    Forum Moderator
    Posted 3 years ago #

    This topic is marked as "resolved"... yet there is nothing other than the original post

    Unfortunately, if the original poster didn't see fit to post their solution to their problem,, there's not a lot we can do.

    Twenty Ten does not use the simple wp_list_pages function

    It uses wp_nav_menu - which in turn falls back to wp_page_menu if no custom menu has been defined. You'll finds that wp_page_menu has an exclude parameter similar to wp_list_pages.

  4. WPcompass
    Member
    Posted 3 years ago #

    Thanks esmi,

    First, I gotta correct myself - the menus subpanel DOES accommodate child pages (drag and drop, like widgets). yay!

    BUT for my current project, it would be great to pass the "exclude page" argument via <?php wp_page_menu('exclude=80' ); ?> (example where page id=80).

    .... I just don't know where to edit or add the wp_page_menu function.

    Can you provide further guidance?

  5. esmi
    Forum Moderator
    Posted 3 years ago #

    You should be able to add this via a function that amends/filters the normal output of wp_page_menu. Something like:

    // Exclude specific pages in wp_page_menu
    if( !function_exists( 'mytheme_page_exclude' ) ) :
    function mytheme_page_exclude( $args ) {
    	$args['exclude'] = '80';
    	return $args;
    }
    endif;
    add_filter( 'wp_page_menu_args', 'mytheme_page_exclude' );

    in functions.php should do it.

  6. WPcompass
    Member
    Posted 3 years ago #

    Woo Hoo, it works! I've applied my first filter in WordPress!!

    Thank you so much, esmi. I'll always remember my first.

  7. esmi
    Forum Moderator
    Posted 3 years ago #

    lol! From now on, it gets really interesting.

    Glad to have helped. :-)

  8. MPESGT01
    Member
    Posted 3 years ago #

    Hi
    same here... would like too fix it inside my header file. Is it possible ? I have include a text in the menu line here
    its inside php <>...
    wp_nav_menu( array( 'exclude=6', 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );

Topic Closed

This topic has been closed to new replies.

About this Topic