WordPress.org

Forums

Child Pages in Navigation Problem (2 posts)

  1. ioushirts
    Member
    Posted 4 years ago #

    I'm working on http://www.mindlitmedia.com that currently has three parent pages (Home, About, Services) and one Child page called Business Logo Design that is underneath the Parent page called Services.

    I want the child pages to appear in the lower secondary menu only when a user is on its parent page.

    I altered the header.php for the secondary menu to read this:

    <?php
    $children = wp_list_pages('title_li=&child_of='.$post->ID.'');
    if ($children) { ?>
    
          <?php echo $children; ?> 
    
    <?php } ?>

    However, while the child page Business Logo Design does appear on its parent page Services, now the two parent pages About and Services are being repeated on the secondary menu on the home page.

    What am I doing wrong?

  2. ioushirts
    Member
    Posted 4 years ago #

    So I figured out how to exclude the two parent pages from repeating, now it's only showing the one real child page called Business Logo Design. So now it looks like this:

    <?php
    $children = wp_list_pages('exclude=2,25&title_li=&child_of='.$post->ID.'&echo=0');
    if ($children) { ?>
      <?php echo $children; ?> 
    
    <?php } ?>

    My next question is, how can I hide the Child page named Business Logo Design from the home page? I only want it to appear on the navigation when someone is visiting its Parent page > Services

Topic Closed

This topic has been closed to new replies.

About this Topic