pierrebalian
9/25/2017 - 5:40 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' );