Howdy,
We are using WP as a lost-cost CMS solution for some intranet websites, so the site mainly consists of pages. I currently have a left-nav that consists of the parent page and child pages, that is generated by the following:
<div id="sidebar">
<?php
if($post->post_parent)
$children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<li class="top">
<?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
</li>
<?php echo $children; ?>
</ul>
<?php } ?>
Which is fine, except, the parent page item is not a link, so I need to make it a link.
I tried adapting various versions of:
<?php if($post->post_parent) {
$parent = $wpdb->get_row("SELECT post_title FROM $wpdb->posts WHERE ID = $post->post_parent");
$parent_link = get_permalink($post->post_parent); ?>
<a href="<?php echo $parent_link; ?>">Back to <?php echo $parent->post_title; ?></a>
<?php } ?>
which I got from the forums here. And while it would sort of work, it is applying extra classes that are causing the layout to get hosed.
What I need is a cleaner way of adding the parent page link at the top of the navigation so I can style it from my master css. (I'm applying all my styles based on the div ID, ingoring the WP classes in this case).
Any ideas?...