• Hello,

    I am using two menues: one in the header of the each pages to display the first level menu (without children pages). The second menu gets only displayed on the left sidebar if there are children in a page (a page in a page). For this second level menu I use the following code in sidebar.php:

    global $post;
    $page_id = $post->ID;
    wp_list_pages(“child_of=$page_id&title_li=”);

    Now my problem is that when I click on a second level page (the page in a page) the menu on the left side disappears but I would like to keep it, how can I do that ?

    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • You have to create a page template for the child pages which uses

    wp_list_pages(“child_of=xx&title_li=”);

    Change xx with the ID of the page which has the children pages.

    This does require you to create a new template for each children page which is not under the same parent.

    I haven’t tried this my self you might also be able to use

    wp_list_pages(“child_of=$post->post_parent&title_li=”)

    Again i haven’t tried this argument, but i’ve read it should work ?? Then you don’t have to create new templates but just one! ??

    Thread Starter mlnosp

    (@mlnosp)

    Thank you MadsK for the great idea of using post_parent. Thank to you I could solve my problem like this without requiring any extra template pages:

    if( $post->post_parent )
    		$page_id = $post->post_parent;
    	else
    		$page_id = $post->ID;
    	wp_list_pages("child_of=$page_id&title_li=");

    I’m glad i could help ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to still get the menu displayed in child pages’ is closed to new replies.