Number of posts on archive page

Let’s try this, as I’m just having trouble with something roots related:

The number of posts seems to be set to 1 on archive pages (at least on the page of a tag), I’d like to increase it. According to the internet a code like this in functions.php should do the job:

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');

I tried inserting it into custom.php and also functions.php but without any result. Does someone have an idea how to increase the number of posts on a tag page?


Not sure if this can work. But when you start the wordpress loop, you have to set this variable

$args = array(
	'post_type'        => 'programas',
	'posts_per_page'   => 15
$programas = new WP_Query($args);

then you can make your loop

<?php while ( $programas->have_posts() ): $programas->the_post(); ?>
 <?php // do stuff ?>
<?php break; endwhile ?>

hope this helps.

Using pre_get_posts is the right way of doing things but I’ve not been able to replicate the issue with your code. Can you please try switching themes to see if the problem persists?

Example of using pre_get_posts with a custom post type:

 * Custom posts per page for Band archive
function botb_band_ppp($query) {
  if (is_post_type_archive('botb_band')) {
    $query->query_vars['posts_per_page'] = -1;
  return $query;
if (!is_admin()) {
  add_action('pre_get_posts', 'botb_band_ppp');

I found a very trivial solution to my problem: simply setting it in the Wordpress settings.
Settings -> Reading -> Max Blogposts per Page was set to 1. Changing that obviously also affects tag and other archive pages.

Thanks for your efforts anyways, hopefully someone else will benefit from it :slight_smile: