Last active
August 8, 2018 06:52
-
-
Save bherrero/94231b8469592448e7d24df4243e6e29 to your computer and use it in GitHub Desktop.
Get all the posts for a CPT archive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre_get_posts to get all the posts por the CPT Archive | |
add_action( 'pre_get_posts', 'pre_get_posts_archive_custom_cpt' ); | |
function pre_get_posts_archive_custom_cpt( $query ) { | |
if( is_admin() ) { | |
return; | |
} | |
if ( $query->is_post_type_archive( 'custom_cpt_name' ) && $query->is_main_query() ) { | |
$query->set( 'posts_per_page', -1 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment