Solved

Wordpress Custom Sidebar Sub-navigation

Posted on 2011-03-15
3
497 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

726 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