Sidebar help
-
I am using this code in my sidebar:
‘<?php /* Creates a menu for pages beneath the level of the current page */
if (is_page() and ($notfound != ‘1’)) {
$current_page = $post->ID;
while($current_page) {
$page_query = $wpdb->get_row(“SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = ‘$current_page'”);
$current_page = $page_query->post_parent;
}
$parent_id = $page_query->ID;
$parent_title = $page_query->post_title;if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_status != ‘attachment'”)) { ?>
<div class=”sb-pagemenu”><h2><?php echo $parent_title; ?> Subpages</h2>
- <?php wp_list_pages(‘sort_column=menu_order&title_li=&child_of=’. $parent_id); ?>
- <?php if ($parent_id != $post->ID) { ?>
Back to ” ><?php echo $parent_title; ?>
<?php } ?></div>
<?php } } ?>’Problem is the “Back to” part only shows the site plus the date of the post. How can I make it so the post Back to “Fruit” is linked to Fruit, which is a parent page?
Also, if the parent has no subs, can it not show any <h2></h2> at all?
- The topic ‘Sidebar help’ is closed to new replies.