pierrebalian of Rocket55 Web Team
8/22/2017 - 6:24 PM

set query parameters on a standard loop without writing a custom wp query using pre_get_posts filter

set query parameters on a standard loop without writing a custom wp query using pre_get_posts filter

//set posts per page for videos post type//
function set_posts_per_page_for_videos_cpt( $query ) {
  if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'videos' ) ) {
    $query->set( 'posts_per_page', '-1' );
  }
}
add_action( 'pre_get_posts', 'set_posts_per_page_for_videos_cpt' );