WordPress.org

Ready to get started?Download WordPress

Forums

Navigation disappears after 3rd child (8 posts)

  1. 2bak860
    Member
    Posted 4 years ago #

    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 } ?>
  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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 (||)?

  3. 2bak860
    Member
    Posted 4 years ago #

    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.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    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 } ?>
  5. 2bak860
    Member
    Posted 4 years ago #

    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.

  6. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  7. 2bak860
    Member
    Posted 4 years ago #

    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!

  8. 2bak860
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.