Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am seeking two codes which I haven't been able to find which would allow a child menu to be created in a sidebar.

A code to display the sub-categories of the parent category.

A code to display the sub-pages of the current page.

I remember having a theme that had these codes implemented which also allowed styling to be applied to current categories. Maybe it has since been depreceated and maybe not - but I would sure appreciate if anybody had more information on these codes.

share|improve this question
add comment

1 Answer 1

for sub-pages of current page check wp_list_pages()

<?php 
  $page_id = get_the_ID();
  wp_list_pages( array( 'child_of'=>$page_id ) );
?> 

and for sub-categories of the parent category check wp_list_categories()

<?php 
$cat_id = get_query_var('cat');
if( !empty($cat_id) ) {
  wp_list_categories( array( 'child_of'=> $cat_id ) );
}
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.