Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ssamik

    (@ssamik)

    Solved… Found this page: https://codex.www.ads-software.com/Template_Tags/wp_list_pages

    Used this one:

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } ?>

    to list subpages even if on a subpage, and it works like a charm.

    I’m using a free theme called “Simplicity”. I used the above code to display the child menu items but it doesn’t work. I’m pasting the code from the files “header.php” and from “style.css”. I hope you could shed some light on this because I’m stumped.

    Excerpt from “header.php” file:
    <div id=”headermenu”>

      <?php
      if($post->post_parent)
      $children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″); else
      $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
      $string = wp_list_pages(‘title_li=&echo=0&depth=1’ );
      $pattern = ‘ current_page_item “‘;$replacement = ‘” id=”current”‘;
      echo str_replace($pattern, $replacement, $string); ?>
      if ($children) { echo $children; }

    </div><!– headermenu –>

    Excerpt from “style.css” file:
    /* headermenu */
    #headermenu {
    padding: 0 1em;
    width: auto;
    background: transparent;
    font-family: ‘Lucida Grande’, Verdana, Helvetica, Sans-Serif;
    }
    #headermenu ul {
    font-size: 11px;
    font-weight: bold;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 0;
    }
    #headermenu li {
    display: inline;
    margin: 0;
    padding: 0;
    text-transform: uppercase;
    }
    #headermenu li:first-child { margin-left: 10px; }
    #headermenu a {
    float: left;
    line-height: 1em;
    display: block;
    background-color: #58a;
    color: white;
    margin: 0 10px 0 0;
    padding: 0.5em 10px;
    }
    #headermenu a:hover {
    background-color: #7ac;
    text-decoration: none;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to show child pages?’ is closed to new replies.