Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Wordpress Custom Sidebar Sub-navigation

Posted on 2011-03-15
3
Medium Priority
?
502 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.
Suggested Courses

604 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