I have been busy lately making some extra money doing side-jobs with WordPress. In WordPress, you will be able to create a “sub-page” by selecting a “Parent”. This tip is useful when you want to retrieve all the sub-pages. You should be able to use this code anywhere in your template files.
<?php global $post; $args = array( 'title_li' => 'More Under This Page', 'child_of' => $post->ID ); $children = get_pages($args); if($children): ?> <div class="subpages"> <ul> <?php wp_list_pages($args); ?> </ul> </div> <?php endif; ?> |
If your page has sub-pages / children under it, then it should display this HTML:
<div class="subpages"> <ul> <li class="pagenav"> More Under This Page <ul> <li class="page_item page-item-46"> Subpage 1 </li> <li class="page_item page-item-49"> Subpage 2 </li> </ul> </li> </ul> </div> |
thanks dude… helped me a lot!
Thanks for the tip on sub pages. I need to create one and will give it a try. I really struggle to find good info. THANKS! Mags @ Child Safety
Pingback: What Is The Best Seo Tactics For The Subpages Of The Site? | freearticlesdbonline.com
Hi Wenbert,
thank you very much for this code, I was actualy looking for one for a while. It really is helpfull in creation of a right side category menu. You are the man!!