WordPress Child Page Menu (parent & subpages)

WordPress Child Page Menu (parent & subpages)

3
49
SHARE

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:
https://twitter.com/learnwebcode

49 COMMENTS

  1. those who got problem in functions
    index.php

    <?php
    if($post->post_parent){
    $args = array(
    'child_of'=>$post->post_parent,
    'title_li'=>null
    );
    }
    else{
    $args = array(
    'child_of'=>$post->ID,
    'title_li'=>null);
    }
    ?>
    <?php wp_list_pages($args) ?>п»ї

  2. 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п»ї

  3. 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…п»ї

  4. 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п»ї

  5. 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.п»ї

  6. 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?п»ї

  7. 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 ;
    }п»ї

  8. 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).п»ї

LEAVE A REPLY