Support » Themes and Templates » Limit first level navigation items – list_pages

  • Hi,

    I’m right now working on my theme wp-creativix and I have a fixed width navigation bar. My problem is, that I want to limit the number of first-level pages that are shown in menu.
    Perfect would be If it is possible to limit the total amount of chars used in first level pages. So that If someone has more than 250 chars in total for his first level pages, a new page will not be shown in menu.
    I think this is a bit tricky, but maybe someone has an idea.

    Cheers, Dennis

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi


    Forum Moderator

    Did you read my question?
    I need to limit the first level navigation output, nothing is written about that on your linked page (which I already red a couple of times).

    Probably need to use Function_Reference/get_pages and craft your own output.

    Or use a query_posts for post_type=page.

    Ian Stewart


    Theme Wrangler

    You could limit the number of first level pages, and only the first level pages, with something like this:

    echo '<ul>';
    	$parent = get_pages('sort_column=menu_order&parent=0&number=6');
    	foreach($parent as $page) {
    		echo '<li>';
    		echo '<a href="' . get_permalink() . '" title="' . $page->post_title . '">';
    		echo $page->post_title;
    		echo '</a>';
    		$postparent = $page->ID;
    		$child = get_pages("sort_column=menu_order&child_of=$postparent");
    		if ($child) {
    		echo '</li>';
    	echo '</ul>';

    In the example above I’m limiting the number of pages to “6” using the number parameter. It’s not limiting by number of characters but I hope this helps you get closer to your solution.

    Good luck!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Limit first level navigation items – list_pages’ is closed to new replies.