Modifying Post Type Archive Query
-
Im using the following code to modify the ‘posts_per_page’ parameter of a Custom Post Type & Custom Taxonomy Archive, problem is that it is also modifying the Main Blog Page (is_home) query:
function list_all_posts($query) { if ( !is_admin() && $query->is_main_query() && ( is_post_type_archive('custom_post_type') || taxonomy_exists('custom_taxonomy') ) ) { $query->set( 'posts_per_page', '-1' ); } } add_action('pre_get_posts','list_all_posts');
Have also tried:
function list_all_posts($query) { if ( !is_admin() && $query->is_main_query() && !is_home() && ( is_post_type_archive('custom_post_type') || taxonomy_exists('custom_taxonomy') ) ) { $query->set( 'posts_per_page', '-1' ); } } add_action('pre_get_posts','list_all_posts');
I only want to change the query of the Custom Post Type & Custom Taxonomy Archive and leave the default Main Blog Page intact so ‘Blog pages show at most’ can be modified in Settings > Reading as it normally would.
Any help would be very much appreciated.
Cheers!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Modifying Post Type Archive Query’ is closed to new replies.