Hi,
I've got my menu bar to show the parent first, then all first tier subpages of the current page/subpage i'm on. However, when i'm on my blog page, I want the name of the blog page first, then all first tier categories to show instead.
The following code is half working. Everything displays how I want it to when i'm on a normal page or subpage, but when i'm on the blog/category page I get a blank menu bar.
<div id="horizontalmenu">
<?php
$cat = get_query_var('cat');
$category = get_category($cat);
//if you are on a page NOT a cat
if ($post->ID) {
$permalink = get_permalink($post->post_parent);
$parent_title = get_the_title($post->post_parent);
//if you are on the sub page display the parents sub pages
//if you are on a page display the sub pages
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 you are on a cat
if ($category->cat_ID) {
$permalink = get_permalink($category->category_parent);
$parent_title = get_the_title($category->category_parent);
$children = wp_list_categories("orderby=id&hide_empty=0&title_li=&child_of=".$category->category_parent."&echo=0");
}
if ($children) { ?>
<div id="hmenutext">
<ul>
<li><a href="<?php echo $permalink; ?>"><?php echo $parent_title;?></a> ></li>
<?php echo $children; ?>
</ul>
</div>
<?php } ?>
</div>
I'm new to php and wordpress, so i'm probably missing something obvious... thanks in advance for any help.
David Kirkpatrick