• Stumped on this one, I’ve been playing with it but can’t figure it out because I don’t have real strong PHP skills.

    I have two tabs that are designed to display all posts that are “blog” and another that are “listings”. However on the left menu, under each tab, it gives both parent’s along with the children.

    Here is the code:

    `<?php
    if (is_category() || is_single()) {
    foreach(get_the_category() as $cat) {
    $id = $cat->cat_ID;
    }
    if (in_or_sub_of($id)) {
    echo ‘<div class=”sidebar”>’;
    echo ‘

      ‘;
      echo preg_replace(‘/>[^<]*?-/’, ‘>’, wp_list_categories(“child_of=$cat->parent&echo=0&title_li=”));
      echo ‘

    ‘;
    echo ‘</div>’;
    }

    } else if (is_page()) {
    /* Menu for subpages of current page */
    if($post->post_parent) {
    $parent = wp_list_pages(“title_li=&include=”.$post->post_parent.”&echo=0″);
    $children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
    } else {
    $parent = wp_list_pages(“title_li=&include=”.$post->ID.”&echo=0″);
    $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
    }
    if ($children) {
    echo ‘<div class=”sidebar”>’;
    echo ‘

      ‘;
      echo $parent;
      echo $children;
      echo ‘

    ‘;
    echo ‘</div>’;
    }
    } else if (is_search()) {
    echo ‘<div class=”sidebar”>’;
    echo ‘

      ‘;
      echo wp_list_categories(“depth=1&title_li=”);
      echo ‘

    ‘;
    echo ‘</div>’;
    } else {
    echo ”;
    }
    ?>`

    What do I need to ‘hack’ to get only the children to show?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Find below and comment out in your code.
    echo $parent;
    to
    #echo $parent;

    Thread Starter kevin20007

    (@kevin20007)

    hmm doesn’t seem to be doing it. I tried adding the # and also just removing the line, but I’m still getting

    PARENT1
    PARENT2
    CHILD1
    CHILD2

    On my menu display. I only see the one instance of

    echo $parent;

    Am I missing something?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Don’t want parent to be displayed, need to change PHP but what line?’ is closed to new replies.