WordPress Child Page Menu (parent & subpages)

WordPress Child Page Menu (parent & subpages)


In this lesson we learn about “parent” and “child” pages in WordPress. We also learn how to code a menu that will output links to any children pages relative to the currently viewed page. Check out my “Git a Developer Job” course: deal thru Tuesday November 8th: https://www.udemy.com/git-a-web-developer-job-mastering-the-modern-workflow/?couponCode=19—–YOUTUBE

To view a complete list of the WordPress lessons in sequential order visit:

Learn WordPress

Link to download .zip of theme files as shown in this video (note: this is not a “complete” WordPress theme yet and this download is only intended for educational purposes to dissect and review):

WordPress Child Page Menu (parent and subpages)

Want to share the WordPress website that you’ve been creating on your computer with the world? Learn about the web host I use and how you can get a domain + hosting for $4.95 a month ($60 savings): http://learnwebcode.com/web-hosting/

Sign up for my newsletter to receive periodic webDev tips, tricks, resources and coupons. Join the list at http://learnwebcode.com/

Follow LearnWebCode on Twitter for resources and updates:


  1. those who got problem in functions

    $args = array(
    $args = array(
    <?php wp_list_pages($args) ?>

  2. you should get the "hero of the year " award!! This kind of charitable work can only done by a good human being!! Thank You

  3. did something changed ? because the get_top_ancestor part is not working … it works on the parent but shows all the menu list on the childs

  4. when i click on the child page, my child nav is not seen on they child page, and my code is copy of your code ! so what is they problems ?

  5. Great tutorial thanks a lot. Could you please tell me where I find the description to check your code I don't seem to be able to find it anywhere.

  6. For anyone wondering, $post is an in-built variable provided by wordpress. We haven't declared it anywhere, it just comes out of the box

  7. Whats the level limit of children page , i mean ,A Page -> Children -> grand children -> Children of grand children-grand children of grand children ..

  8. For some reason my has_children() function is returning the total number of pages I have.
    Here is my code
    function has_children() {

    global $post;

    $pages = get_pages('child_of =' . $post->ID);
    return count($pages);

    Any help would be appreciated

  9. Hi,

    Can we make category as child of parent page? I mean is it possible to make wp_list_categories() child of a particular page?

  10. With watching few of your videos i got very good insights into wordpress. Thanks for sharing your knowledge! Brad, you simply rock!

  11. its good to have suorce cod for all of this …. i didn notice any link .. if any ….suggest me..please…….

  12. The functions is still displaying the top most level pages only on the initial about us page. I cant seem to get all the pages in the nav list to go away only on the first about us pages. once i click on mission statement or one of the subsequent links it starts to act like your tutorial. please assist me with this issue…

  13. after adding all finctions …..on children pages all pages list is displaying as it was displaying on parent page when we added wp_list_pages..

  14. What's so funny about an empty quote !? huh ?! you think your better than it !? you narcissistic piece of sh*t ?!

  15. Any change wordpress has a way of posing the year a Post was made? like <?php wp_year ?>
    or something?

  16. Hi, great tutorials. Question pls! What if the top level parent page doesn't have a link, what if it's just a placeholder for a dropdown, how do I make it so that that top level menu item doesn't actually have a link to go to.

  17. Thanks for your videos. You have shown me that WordPress is definitely the way forward for me and my site and shown me just how useful this can be!

  18. "Meat and potatoes" (5:15) wow, nice expression. Can't recall if I have heard it before lol. I suppose the British proverb would be "bangers and mash" ha ha

  19. my parent link is displaying afer the children link , it showing on right instead of left side of children link
    i downloaded you zip file but its still no working

  20. How do you get to (or in) the where you can change the different lines in the html. that is marked 2:18 in this video.

  21. I keep getting an error with the final step of the video where the if function is written. Now my about tab has an error. Can any help me out?

  22. I have the child pages displaying like the top level nav items just below the main about nav item. on the child pages i have the ul list unstyled with the title. How do i get rid of the other links in the primary nave area? using WP 4.4.2. Your help is appreciated

  23. I never comment on these videos but I've felt the need to do so now after having this issue happen repeatedly with every single video you've put out for WordPress is this video playlist.

    Do you honestly make these videos with the intention of letting people follow along with you? And if so, why do you burn through all your steps so damn fast? I've had to pause, write lines of code, play the video again, see what you did, forget what you say, step back through the video, and listen to it again after already having everything written down.

    What I'm getting at is that you're honestly rushing through the material too quickly (for me at least), especially if you intend on people following along with you. A perfect example of this is at 13:16, where you copy a previously created CSS selector, paste it twice, modify them, add styling to it, AND THEN jump to the browser to show the changes, ALL IN LESS THAN TEN SECONDS. You do this EVERYWHERE.

    How can you honestly expect people to learn when you speeding through material so quickly? I understand it's a video and I can pause it, and I feel like an asshole for being upset over something so minor, but when I still don't have enough time to see what you did with the video at 0.5 speed, I think you're honestly doing something wrong.

    I don't care if the video is 30 minutes long, I'm going to watch the whole thing if I actually want to learn something. If it being shorter means I have to keep breaking my concentration just to keep up with you, then a 15 minute video becomes 30 minutes already when I have to listen to it at 0.5 speed. Add to that the frustration of having to double back and make sure I didn't miss anything, and I end up wasting more time trying to learn from a video that could be slightly longer to save me the trouble of having to do that in the first place.

  24. I have a huge problem and I can't figure it out: The child links are being displayed all the time, not just when the parent link is selected. Also, in the css file, this whole block of code is not allowing the current menu Item or page ancestor to stay lit up when selected:

    .site-header nav ul li.current-menu-item a:link,
    .site-header nav ul li.current-menu-item a:visited,
    .site-header nav ul li.current-page-ancestor a:link,
    .site-header nav ul li.current-page-ancestor a:visited

    I even copied and pasted the source code accompanied with this lesson directly into notepad++ with no luck. I am using WordPress 4.4.2. Any suggestions?

  25. IF I use below code, then instead of block only hyperlink background color changes to black in my nav menu. whats wrong?

    .site-header nav ul li.current-menu-item a:link,
    .site-header nav ul li.current-menu-item a:visited,
    .site-header nav ul li.current-page-ancestor a:link,
    .site-header nav ul li.current-page-ancestor a:visited {
        background-color: black;
        color: #FFF;

  26. good day sir, .is their any way how make like that if i have Parent Category and have a child? i am using custom taxonomy sir, .
    parent | child child child child—taxonomy

  27. I appreciate the effort, but it should be done with a wp_nav_menu, not with wp_list_pages. With wp_nav_menu you can control the order and actual menu hierarchy (not always the the page hierarchy reflects the menu hierarchy).