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:
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):
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
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) ?>п»ї
you should get the "hero of the year " award!! This kind of charitable work can only done by a good human being!! Thank Youп»ї
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п»ї
muito produtivo, gosteiп»ї
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 ?п»ї
my children-link class is not being applied what should do i am following the code ?п»ї
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.п»ї
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п»ї
My stylesheet isn't working on index.php but all the other files are reading it fine, any ideas?п»ї
Doesn't seem to workп»ї
Anybody know what text-editor he is using?п»ї
thank you , you re amazing!!!п»ї
Whats the level limit of children page , i mean ,A Page -> Children -> grand children -> Children of grand children-grand children of grand children ..п»ї
how can Developer remember all of these Methods or functions and when must use theme , :(п»ї
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п»ї
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?п»ї
thanks for tutorial.п»ї
With watching few of your videos i got very good insights into wordpress. Thanks for sharing your knowledge! Brad, you simply rock!п»ї
its good to have suorce cod for all of this …. i didn notice any link .. if any ….suggest me..please…….п»ї
Where do I find the code window? How do I access it on a mac?п»ї
Really thanks.Do you have any tutorial on Plugin Development?п»ї
hay bro i pay you for simple page please if yes please tell me iwant simple wordpressп»ї
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…п»ї
Is there anyone for my help ? mentioned 5 days ago and still no replyп»ї
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..п»ї
What's so funny about an empty quote !? huh ?! you think your better than it !? you narcissistic piece of sh*t ?!п»ї
Absolutely brilliant tutorial!! Excellent teacher!! The entire course on here is Fantastic!п»ї
Any change wordpress has a way of posing the year a Post was made? like <?php wp_year ?>
or something?п»ї
by using this method you can silo wordpress site!п»ї
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.п»ї
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!п»ї
"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п»ї
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п»ї
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.п»ї
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?п»ї
Unbelievably good teacher, this course is just fantastic all aroundп»ї
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п»ї
Goodness me this video helped me out today. Thanks so much for sharing!п»ї
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.п»ї
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?п»ї
Very elegant solution!! Thx for sharing it!п»ї
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 ;
}п»ї
Very nice series and very well explained.. Thank you very much :)п»ї
good day sir.. i wonder what is this -> operator and what they do.п»ї
keep up the good workп»ї
easy like eating a cake with him. OMGп»ї
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п»ї
You are one of the best teacher there are online. Thank you for a great content.п»ї
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).п»ї