1

I'm trying, without success, to disable pagination only in a specific category (where I'm showing all the posts of that category listed by years). Someone can help me? Thanks.

1

You can try this, replacing my_cat with your category slug. This will modify the main query just before rendering the loop on the archive page of your category.

add_action( 'pre_get_posts', 'wpse_disable_pagination' );
function wpse_disable_pagination( $query ) {

  if( is_category( 'my_cat' ) {
    query->set( 'posts_per_page', '-1' );
  }

}
|improve this answer|||||
0

@bynicolas thanks! One shot, one kill :)

This is the modified sintax of your snippet that worked for me:

add_action( 'pre_get_posts', 'wpse_disable_pagination' );
function wpse_disable_pagination( $query )
{
  if ( is_category( 'newsletter' ) )
  $query->set( 'posts_per_page', '-1' );
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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