WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showing sub categories (3 posts)

  1. MaddTechWF
    Member
    Posted 4 years ago #

    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 http://www.mayfair.org/ministries/ . This site has what I'm trying to create in WordPress.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  3. MaddTechWF
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.