Don’t want parent to be displayed, need to change PHP but what line?
-
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!
- The topic ‘Don’t want parent to be displayed, need to change PHP but what line?’ is closed to new replies.