• Issue 1
    The following code will display everything I want except for the main parent title. What do I need to add to the code to display this? For instance if a user clicks on Page this code will display SubPage1, SubPage2, etc. It will not display the main parent page Page.

    Issue 2
    This code also displays SubSubPages even when the SubPage is not active. I’d like it to only display the SubSubPages when anything in the SubPage is active.

    <?php
      if($post->post_parent) {
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $titlenamer = get_the_title($post->post_parent);
      }
    
      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>
    
      <h2> <? echo $titlenamer ?> </h2>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ajcke

    (@ajcke)

    Thanks. I’m able to display the parent name in the h2 tag now. I left out php before echo.

    Parent
    ——–Child
    —————-childChild

    This code only displays the immediate parent. For instance if a user goes to childChild only child and childChild display in the list. Is there a way to keep the parent in the list when childChild is selected?

    I’m still not able to solve issue 2 above.

    My goal is to achieve a menu like this: https://www.n-union.k12.oh.us/About.aspx. This site basically has 4 menus – District and one for each school. The menu only displays the childchild menus if a page in that ul is selected.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Page Parent in Menu’ is closed to new replies.