WordPress.org

Forums

Limit first level navigation items - list_pages (5 posts)

  1. IWEBIX
    Member
    Posted 5 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 5 years ago #

  3. IWEBIX
    Member
    Posted 5 years ago #

    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).

  4. MichaelH
    Member
    Posted 5 years ago #

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

    Or use a query_posts for post_type=page.

  5. Ian Stewart
    Theme Wrangler
    Posted 5 years ago #

    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) {
    			wp_list_pages("title_li=&sort_column=menu_order&child_of=$postparent");
    		}
    		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!

Topic Closed

This topic has been closed to new replies.

About this Topic