Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Awesome that was exactly what I was looking for. Now if you don't mind me asking you 1 more question related to this that just came up. I am running this code on a Contact page, and I am telling it to pull the child pages of another section. It is doing that now with the snippet you provided but its also pulling the sub pages of the Contact page and I don't want that. Is their a more dynamic way to use the exclude function within wp_list_pages to not show children pages of current page that you are on? Commented Aug 15, 2012 at 18:26
  • If I understand your question, you only want direct children of the parent page shown, right? So instead of child_of, which lists all descendants, use parent=, which only gets immediate children. codex.wordpress.org/Function_Reference/get_pages#Parameters Commented Aug 15, 2012 at 19:32
  • What I am looking to do is show specific child pages of another page. In this example I want to display children pages of the main parent "Services" page on my "Contact Us" page. I also in the back-end of Wordpress have child pages listed under "Contact Us". When you view the front-end of the Contact Us page I only want the child pages of "Services" to show up and not display the child pages at all of the "Contact Us" page. Right now in my sidebar file I have the following: Commented Aug 16, 2012 at 14:28
  • Right now I have: ` <?php } elseif (is_page('58')) { ?> <!--Contact Us Page--> <h4><span>Practice Areas</span></h4> <ul> <? if ($page = get_page_by_path('practice-areas')){ wp_list_pages('orderby=name&depth=1&order=DESC&show_count=0&child_of='.$page->ID.'&title_li='); } ?> </ul> <?php } else { ?> ` Commented Aug 16, 2012 at 14:28
  • Hey @Danny, do you mind updating your original question with the code you pasted into this comment? And of course, make sure you put it inside a SE code block, so it's nice and easy to read. Commented Aug 16, 2012 at 18:08