Solved

Wordpress Custom Sidebar Sub-navigation

Posted on 2011-03-15
3
495 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what do I need to host my own web sites? 13 51
Tracking uptime for a bunch of sites 3 40
help restore my wordpress site made on WAMP 8 29
PHP 5.6 and 7.x 4 23
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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