Home > Software design >  Show more pages in archive pages
Show more pages in archive pages

Time:03-18

I want to increase the number of pages listed in the tag and category archive page. How do I do that?

I tried this code.

add_filter('pre_get_posts', 'limit_change_posts_tag');
function limit_change_posts_tag($query){
if ($query->is_tag) {
    $query->set('posts_per_page', 20);
}
return $query;
}

But the the thumbnail and the title are not wrapping themselves up.

CodePudding user response:

Your error is in the way you filter if is a tag page. You should use is_tag, as simple as that.

This is how it should look

add_action( 'pre_get_posts', 'limit_change_posts_tag' ); 

function limit_change_posts_tag($query) {
    if ( is_tag() ) {
        $query->set( 'posts_per_page', 20 );
    }
}
  • Related