• I’m trying to set up an intelligent archive system for my wordpress entries. So far I’ve done quite well, see http://beingmrkenny.co.uk/blog/blogarchive.php

    You can enter the month and year as GET variables:

    ?month=jan&year=2004

    What I’d like to do would be to set ‘numberposts’ to some sort of “max” value, or “all” so that all posts within the date range were given. So far I have had to enter it at 60, which is the maximum number of posts in any month, but when the number of posts is less than that, empty <li> tags are generated.

    Is there a way to set numberposts to something more sensitive?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I don’t know if you use the loop for that, but you could use something like:

    <?php query_posts(‘showposts=10’); ?>
    (http://codex.wordpress.org/The_Loop)

    before the loop, and have ’10’ as a variable from the GET input.

    Thread Starter maerk

    (@maerk)

    Hmm, that’s interesting, I’ll probably use that idea when displaying all posts from a year.

    For the month, though, is there a way of getting the number of posts in that month. I found

    $wp_query->post_count

    but it seems that I’m only requesting the last 15 posts from each month. Is there a way to request ALL posts from a month?

    EDIT: the reason it’s 15 is because that’s the number of posts per page I’ve set in options. How to override this…

    Maybe something like: if isset get [‘month’] query_posts(‘showposts=10000’), else …

    so if they ask a month, set the number of posts to appear very large and I think they will then see all posts

    Also, be sure to filter the get data for security issues.

    Thread Starter maerk

    (@maerk)

    Cool, thanks for the heads-up on the security issue.

    I don’t know if I can do anything with GET data, though. Does anyone know how to override the setting in options for posts-per-page?

    Or how to count posts within a month?

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