• Resolved jtancil

    (@jtancilyahoocom)


    : Hi,
    I am using WordPress to power a site which has a subnavigation menu on the sidebar. The site has many pages, child pages and grandchildren.

    Using the code below, I can show the titles of all child pages and the titles of all their grandchildren.

    However, I only want to display the title of the current child page and its grandchildren; I don’t want to show links to other child pages nor their grandchildren.

    For instance, on this page (http://www.sitesofconscience.org/sites/accredited-members/gulag-museum) I ONLY want to show the current page title and its grandchildren, so everything from “Gulag Museum” to “Dialogues for Democracy”.

    “Constitution Hill” and the links underneath it are another child page and its grandchildren; I don’t want those links to appear.

    Is there any way to do this, perhaps by modifying the code I have a bit? Or, is there a conditional statement I could use? I have many pages on the site and I’d rather not use menus.

    Thanks for any hints or suggestions.

    <?
    
    	if (in_array($post->post_parent, array(7,217,246,47))) {
    		//if parent is sites page, post own children
    		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");
    	} else {
    		//otherwise, post parent's children
    		$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order");
    	}
    	if ($children) echo "<ul>" . $children . "</ul>";?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Excluding Child Pages on sidebar’ is closed to new replies.