Skip to content

Instantly share code, notes, and snippets.

@wpmark
Last active June 8, 2018 06:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wpmark/6e31f167c3fe6e4e411c to your computer and use it in GitHub Desktop.
Save wpmark/6e31f167c3fe6e4e411c to your computer and use it in GitHub Desktop.
Pre Get Posts to Show All Posts for Custom Post Type Archive
<?php
function wpmark_alter_team_archive_template_query( $query ) {
/* only proceed on the front end */
if( is_admin() ) {
return;
}
/* only on the person post archive for the main query */
if ( $query->is_post_type_archive( 'wpmark_person' ) && $query->is_main_query() ) {
$query->set( 'posts_per_page', -1 );
}
}
add_action( 'pre_get_posts', 'wpmark_alter_team_archive_template_query' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment