• Resolved bgpc

    (@bgpc)


    hello i use satorii theme and it list all the pages and childpages. but i only want it to show main pages.

    the code is here:

    <?php 
    
    	if ( count($post->ancestors) === 0 ) //if it's a top-level page, we'll show all it's children
    	{
    		echo  substr(wp_list_pages('sort_column=menu_order&child_of=' . $post->ID .'&echo=0&title_li=<h3 class="page-links-title">' . get_the_title($post->ID) . '</h3>'), 20, -5);
    	} elseif ( count($post->ancestors) === 1 )  //if it's a second level, we'll show all its parents' children
    	{
    		echo substr(wp_list_pages('sort_column=menu_order&child_of=' . $post->ancestors[0] . '&echo=0&title_li=<h3 class="page-links-title">' . get_the_title($post->ancestors[0]) . '</h3>'), 20, -5);
    	} else //if page it's more than two levels deep, we'll show all of its top-level ancestor's children
    	{
    		echo substr(wp_list_pages('sort_column=menu_order&child_of=' . $post->ancestors[1] . '&echo=0&title_li=<h3 class="page-links-title">' . get_the_title($post->ancestors[1]) . '</h3>'), 20, -5);
    	}
    
    ?>

    i have tried lots of variation but i cant solve it ??

Viewing 1 replies (of 1 total)
  • Thread Starter bgpc

    (@bgpc)

    echo  substr(wp_list_pages('sort_column=menu_order&child_of=' . $post->ID .'&echo=0<strong>&depth=1</strong>&title_li=<h3 class="page-links-title">' . get_the_title($post->ID) . '</h3>'), 20, -5);
    	}

    i solved the problem by adding &depth=1 after &echo=0

Viewing 1 replies (of 1 total)
  • The topic ‘problem with the page and subpage’ is closed to new replies.