• Resolved peli

    (@peli)


    How can I limit the list of pages?
    I am using: <?php wp_list_pages(‘title_li=&sort_column=post_date&sort_order=DESC’); ?>
    but I wolud like to list the only 25 newest pages, not the whole list.
    I can not use the include or the exclude arguments,
    because then I have to change it every day.

    Is there any solution?

Viewing 5 replies - 1 through 5 (of 5 total)
  • https://www.semiologic.com/2005/04/10/wordpress-recent-plugin-collection/

    “Recent updates displays a list of recently updated pages on your WordPress blog.”

    The bad thing is… pages and Pages are two different things in WP. And the OP was asking about Pages.
    (meanwhile the plugin author should make it clear: it is about posts!)

    The best way I think is to write a little function that does the similar job as wp_list_pages. However, here’s an alternative way.

    <?php $pages = wp_list_pages('title_li=&sort_column=post_date&sort_order=DESC&depth=-1&echo=0');
    preg_match_all('/(<li.*?>)(.*?)<\/li>/i', $pages, $matches);
    if (!empty($matches[0])) {
      print '<ul>' . implode("\n", array_slice($matches[0],0,25)) . '</ul>';
    }
    ?>

    Note that this won’t work if depth parameter set to other than -1 when there are child pages.

    “meanwhile the plugin author should make it clear: it is about posts!”

    Yes indeed! He had me fooled!

    Thread Starter peli

    (@peli)

    it seems that the function works fine.

    thanks yoshi

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘limit wp_list_pages’ is closed to new replies.