WordPress Code Snippets to get Parent Child Relationship

<?php 
$parent = $post->ID; // get the id of current page
$child_pages = wp_list_pages("title_li=&child_of=".$parent."&echo=0&sort_column=post_date"); // sort by date and output as li elements
if ($child_pages) { ?>
	<ul class="wrapper-nav">
		<?php echo $child_pages; ?>
	</ul>
<?php } ?>

Advantages of Using this code snippets

Not only this shows the parent child relationship if used properly with breadcrumb navigation, can help in maitaining proper silo strucuture within the website. Silo is quiet a key and integral part of SEO.


About Author

I am Robin - WordPress Developer based in Sydney. I work as Digital Developer. I do some projects now and then, and love blogging about WordPress and Web Design.