Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKonrad Pilch
2,435 PointsPlease explain to me this code of taking sub menu nav and putting it in wp
<?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
}
if ($children) { ?>
<h2> <?php echo $titlenamer; ?> </h2>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
1 Answer
Kevin Korte
28,149 PointsI'll challenge you to figure out how to find your answer on your own. You know these functions live in the WP codex, between that and your knowledge of php you should be able to get the understanding of what the functions are receiving, and what they are returning.
Take a stab at it and let me know.