Title: Automatically set numberposts
Last modified: August 18, 2016

---

# Automatically set numberposts

 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/)
 * 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](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)

 *  [onseduction](https://wordpress.org/support/users/onseduction/)
 * (@onseduction)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354456)
 * 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](http://codex.wordpress.org/The_Loop))
 * before the loop, and have ’10’ as a variable from the GET input.
 *  Thread Starter [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354462)
 * 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…
 *  [onseduction](https://wordpress.org/support/users/onseduction/)
 * (@onseduction)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354492)
 * 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
 *  [onseduction](https://wordpress.org/support/users/onseduction/)
 * (@onseduction)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354493)
 * Also, be sure to filter the get data for security issues.
 *  Thread Starter [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354519)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [maerk](https://wordpress.org/support/users/maerk/)
 * Last activity: [20 years, 3 months ago](https://wordpress.org/support/topic/automatically-set-numberposts/#post-354519)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
