Solved

Wordpress Custom Sidebar Sub-navigation

Posted on 2011-03-15
3
492 Views
Last Modified: 2012-05-11
Hey there!

I am creating a custom Wordpress theme for a site I'm developing and want to add a sub-navigation menu to the sidebar.

So how it will work, once you are on a particular page, if the page has "child" pages, it will post the parent page as a title and the child pages in an unordered list. So something like this:

<h3>Parent Page</h3>
<ul>
<li>Child Page 1</li>
<li>Child Page 2</li>
<li>Child Page 3</li>
</ul>

Open in new window


If a page doesn't have any child pages, I don't want it to show anything.

Can someone lend me a hand? I've found a couple of samples online but none that are exactly what I'm looking for.

Thanks.

P.S. I would prefer to not use a plugin to do this.
0
Comment
Question by:Adam
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Adam earned 0 total points
ID: 35139584
I think I answered my own question :)

<?php
   $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
  
if ($children) { ?>
<h3>
<?php $parent_title = get_the_title($post->post_parent);
echo $parent_title; ?>
</h3>
<ul>
<?php echo $children; ?>
</ul>

Open in new window

0
 
LVL 1

Author Closing Comment

by:Adam
ID: 35139589
I did a little more sleuthing on my own and discovered a solution. No need for experts! :)
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35140022
Good work, furio13!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now