Support » Fixing WordPress » Wp_nav_menu() to display ONLY submenu pages

  • Hello,

    do you know a way to use the wp_nav_menu() function to display ONLY 2nd level pages?

    Pratically, I have a page with children pages and I would like to display a menu with ONLY that subpages.

    Thank you! 😀


Viewing 2 replies - 1 through 2 (of 2 total)
  • I know that solution… hope that works for you…

    in functions.php

    //display child pages of the current page
    if ( !function_exists('get_children_pages') ) {
    	function get_children_pages() {
    		global $wp_query;
    		if ( empty($wp_query->post->post_parent) ) {
    			$parent = $wp_query->post->ID;
    		} else {
    			$parent = $wp_query->post->post_parent;
    		wp_list_pages( 'title_li=&child_of=' . $parent . '&depth=' );

    in your page.php where the subpages should be shown…
    <?php get_children_pages(); ?>

    Does that work for you?

    Hi egado. The function you posted is for wp_list_pages, instead of wp_nav_menu. Do you know of a function that will work for wp_nav_menu?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wp_nav_menu() to display ONLY submenu pages’ is closed to new replies.