Support » Fixing WordPress » Showing sub categories

  • Resolved MaddTechWF


    I was wondering if anyone could help me with a menu question.

    I have children of a menu item and I don’t want them to show below the section. I was wondering if someone knew how to code it so that if a menu item that has children is clicked, it will then show the children in a menu in the sidebar. I would great appreciate any help… Reference site is . This site has what I’m trying to create in WordPress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi


    Forum Moderator

    I’ve not tried displaying the sub-pages in the side bar but:

    // List  child pages
    function theme_subpages($this_page) {
    	if (is_page()) {
    		if ($post->post_parent) $this_page= $post->post_parent;
    		$children = get_page_children($this_page, get_pages());
    		if($children) {
    			$subpages = '<div class="subpages"><h3>' . __('Pages in this section')  . '</h3><ul>';
    			foreach($children as $child) {
    				$subpages .= wp_list_pages('title_li=&include='.$child->ID.'&echo=0');
    			$subpages .= "</ul></div>\n";
    	return $subpages;

    added to functions.php and then:

    <?php if (function_exists('theme_subpages') ) echo theme_subpages($post->ID);?>

    within the Loop in page.php will list the sub-pages in the post content area.

    Is this going to display the Child’s name or ID?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing sub categories’ is closed to new replies.