I am trying to display all posts from a selected month.

Currently once I select a month, only 10 posts display. I understand I can increase the amount of posts to show under the 'reading' options within the dashboard.

I want to be able to keep the front posts page to display 10 posts but the 'archive' pages to display all posts.

Any help appreciated.


2 Answers 2


You can use the pre_get_posts action to set posts_per_page to -1 on the monthly archive pages.

I said wrongly in a comment to use is_archive() as your conditional. The problem with is_archive() is, it returns true on all archives, which includes category and taxonomy archive pages as well.

I would suggest to make use of is_date() and is_month() if you specifically needs to target montly archives

(Please note, the following code is untested and needs PHP 5.3+)

add_action( 'pre_get_posts', function ( $query ) {
    if ( !is_admin() && $query->is_date() && $query->is_month() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', '-1' );
  • My pleasure, glad it worked :-) Enjoy Commented Nov 27, 2014 at 12:47
<?php $oct_04 = get_month_link('2004', '10'); ?>


1) If year and month parameters are set to '', the tag returns the URL for the current month's archive.

2) Returns URL to the archive for October 2004, assigning it to the variable $oct_04. The variable can then be used elsewhere in a page.

  • 1
    You code returns the link to a monthly archive, that is not what the OP is asking.
    – cybmeta
    Commented Nov 27, 2014 at 12:28
  • Please make sure that you understand what is been asked. If you are unsure, please ask for clarification before posting irrelevant information. :-). This not only saves you time, but is saves everyone's time landing on this post Commented Nov 27, 2014 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.