WordPress.org

Support

Support » How-To and Troubleshooting » Navigation disappears after 3rd child

Navigation disappears after 3rd child

  • I’ve got the following navigation – but for some reason the third page down the tree won’t show the navigation. Can anyone help?

    <?php if ( is_page('home') || $post->post_parent == '455' ) { ?>
    <?php wp_list_pages('title_li=&include=281,1579,182&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( in_category( 'alpha' )) { ?>
    <?php wp_list_pages('title_li=&include=493,698,3100,3095,3087,3111,509&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( is_page('alpha') || $post->post_parent == '492' ) { ?>
    <?php wp_list_pages('title_li=&include=493,698,3100,3095,3087,3111,509&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( in_category( 'beta' )) { ?>
    <?php wp_list_pages('title_li=&include=622,3082,3088,3090,511,78,160&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( is_page('beta') || $post->post_parent == '446' ) { ?>
    <?php wp_list_pages('title_li=&include=622,3082,3088,3090,511,78,160&sort_column=menu_order&depth=1'); ?>
    
    <?php } else { ?>
    
    <?php } ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    @esmi

    Forum Moderator

    There’s a flaw in the logic:

    <?php } elseif ( in_category( 'alpha' )) { ?>
    <?php } elseif ( is_page('alpha') || $post->post_parent == '492' ) { ?>
    
    <?php } elseif ( in_category( 'beta' )) { ?>
    <?php } elseif ( is_page('beta') || $post->post_parent == '446' ) { ?>

    If a post is in category alpha or beta, it will stop at the first line of each doublet. So the second line will never get processed. Also, did you meant AND (&&) instead of OR (||)?

    Hi Esmi,

    Thanks for your help. I’m trying to get it so that every child under the alpha parent, and including the parent shows something, and every child under the beta parent, and including the parent shows something else.

    I thought that if I say “if is_page('alpha') or (II) alpha (492) is the parent, show this…

    What would be the fix (where has my logic gone wrong?!)?

    thanks, Ross.

    esmi

    @esmi

    Forum Moderator

    I think you just over-complicated it a little. Try just using:

    <?php if ( is_page('home') || $post->post_parent == '455' ) { ?>
    <?php wp_list_pages('title_li=&include=281,1579,182&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( is_page('alpha') || $post->post_parent == '492' ) { ?>
    <?php wp_list_pages('title_li=&include=493,698,3100,3095,3087,3111,509&sort_column=menu_order&depth=1'); ?>
    
    <?php } elseif ( is_page('beta') || $post->post_parent == '446' ) { ?>
    <?php wp_list_pages('title_li=&include=622,3082,3088,3090,511,78,160&sort_column=menu_order&depth=1'); ?>
    
    <?php } else { ?>
    
    <?php } ?>

    Thanks Esmi.

    Unfortunately it doesn’t work 3 levels down, i.e.

    root.com/parentpage/childpage/toypage

    Is it a bug in list pages?
    thanks, Ross.

    esmi

    @esmi

    Forum Moderator

    When you say it doesn’t work, in what way? In terms of the list of displayed pages not going down deep enough? Or is it that the list isn’t displayed on grandchild pages? Only you’re testing on specific $post->post_parent ids that won’t be valid by the 3rd level.

    Only you’re testing on specific $post->post_parent ids that won’t be valid by the 3rd level.

    Oh I see! What would be valid to get the 3rd level?

    thanks Esmi!

    Found a solution – thanks Esmi

    http://wordpress.org/support/topic/244108?replies=3

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Navigation disappears after 3rd child’ is closed to new replies.
Skip to toolbar