pre get posts custom post type archive

Solutions on MaxInterview for pre get posts custom post type archive by the best coders in the world

showing results for - "pre get posts custom post type archive"
Sofie
24 Sep 2017
1<?php
2function wpmark_alter_team_archive_template_query( $query ) {
3    
4    /* only proceed on the front end */
5    if( is_admin() ) {
6	    return;
7    }
8    
9    /* only on the person post archive for the main query */
10    if ( $query->is_post_type_archive( 'wpmark_person' ) && $query->is_main_query() ) {
11	    
12        $query->set( 'posts_per_page', -1 );
13        
14    }
15    
16}
17
18add_action( 'pre_get_posts', 'wpmark_alter_team_archive_template_query' );
19?>