Blog

How to create a sidebar navigation in WordPress

Here’s a snippet that will give you an instant sidebar navigation in WordPress. It grabs the post parent title and the children of that parent.

Download wordpress-sidebar-nav.txt

< ?php
$parent_title = get_the_title($post->post_parent);
$permalink = get_permalink($post->post_parent);
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');
}
?>

< ?php if ($children): ?>


< ?php endif; ?>

Related posts:

  1. How to Create Books in Coda
  2. How to create a CSS3 border fadeout
  3. How to create a custom Apple iPad/iPhone Home screen icon for your Website

Comment on this article: