WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

for sub-pages of current page check wp_list_pages()

  $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()

$cat_id = get_query_var('cat');
if( !empty($cat_id) ) {
  wp_list_categories( array( 'child_of'=> $cat_id ) );
share|improve this answer

Your Answer


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.