Print this Post

WordPress: Change Number of Posts on Archive Page

WordPress archive pages include category archive, tag archive, yearly archive etc., WordPress shows same number of posts on archive pages as you’ve set for blog page on reading settings. There isn’t any option to change number of posts on archive pages. But here is a simple solution to change it.

Here is a custom function to change number of posts on archive pages. Add this to your theme/child-theme’s functions.php file. It’s a php function. So, put this code anywhere between opening and closing php tags. (between <?php and ?>)

function number_of_posts_on_archive($query){
    if ($query->is_archive) {
            $query->set('posts_per_page', 15);
    return $query;
add_filter('pre_get_posts', 'number_of_posts_on_archive');

This will show 15 posts on all archive archive pages. You can limit this to only category archive page or tag archive page using conditional tags. For example, changing $query->is_archive to $query->is_category will show 15 posts when any Category archive page is being displayed. Likewise changing this to $query->is_tag will show 15 posts when the tag archive page is being displayed. You can also combine multiple conditional tags like this,

if ($query-> is_category() || is_tag() ) {
            $query->set('posts_per_page', 15);

This will show 15 posts only on category and tag archive pages. Other archive pages will show same number of posts as blog page.

Other conditional tags for archive pages, (taken from here)

is_date() – When any date-based archive page is being displayed
is_year() – When a yearly archive is being displayed.
is_month() – When a monthly archive is being displayed.
is_day() – When a daily archive is being displayed.
is_time() – When an hourly, “minutely”, or “secondly” archive is being displayed.
is_search() – When a search result page archive is being displayed.
is_404() – When a page displays after an “HTTP 404: Not Found” error occurs.

Obviously, you can change the number of posts in the 3rd line of the code.

Short Link:

About the author

Prasanna SP

Student | WordPress Dev | Tech Blogger | Interested in GNU/Linux, FOSS, PHP, Drupal, WordPress, Ethical hacking, Photography, Painting, Literature etc..

Permanent link to this article: http://www.prasannasp.net/wordpress-change-number-of-posts-on-archive-page/


1 ping

Skip to comment form

  1. Ironhide

    Thanks Man 🙂 I was searching for hours!

  2. Traveller

    Thank you Prasanna!
    I was also searching for hours on how to show multiple posts on the WordPress “Tag Archives” page and you showed me how to do it. Easily! Now users can see a longer list and choose the post they want rather than scrolling through all of the posts page-by-page one at a time!

    OK now I gotta figure out how to add a thumbnail image to the results as well, hope some smart guy like you has already explained it.

  3. luis

    thank you very much for this info. it has been very helpful

    I still have a limit on my frontpage that shows my latest posts. do you know how could i edit the number of posts on this frontpage ??
    i tried via the panel ( reading-show number of posts ) but this is not working
    so it would be much appreciated if you could help me with this
    have a great day, Luis

  4. Andru


    I couldn’t find this info anywhere else. Tried a lot of other solutions, but none of them worked.

    Thanks a lot!

  5. Ronan

    Thanks man! All this running around in circles to find fixes reminds me how much I hate working with WordPress/am unable to work with WordPress/am sorely lacking in coding skills.

  6. Movie

    Thank you so much Prasanna, this tutorial very useful. I have search more than 3 days, and now I found the solution in thin blog.

  1. Change Number of Posts Displayed on Archive Page - Katherine Goodmanson

    […] This function, when added to functions.php, will help you add a posts_per_page query to the archive.php and archives.php pages, enabling you to further customize the output. Sourced from here […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code snippet between <code> and </code>. Comment moderation is in use. Please do not submit your comment twice -- it will appear shortly.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.