You appear to be a bot. Output may be restricted
Description
Implement "pre_get_posts" action for oik-types for archive pagesThere should be no need to access "bw_types" since the fields should already have been copied to the post_type definition. For taxonomy archives we find the highest number of posts per page for the post_types involved in the query.
Usage
oik_types_pre_get_posts_for_archive( $query );
Parameters
- $query
- ( object ) required – Instance of WP_Query
Returns
voidSource
File name: oik-types/oik-types.phpLines:
1 to 21 of 21
function oik_types_pre_get_posts_for_archive( $query ) { if ( $query->is_main_query() ) { if ( $query->is_archive() ) { $archive_posts_per_page = null; $post_type = bw_array_get( $query->query, 'post_type', null ); if ($post_type ) { $archive_posts_per_page = oik_types_get_archive_posts_per_page( $post_type ); } elseif ( $query->is_tax() || $query->is_category() ) { $archive_posts_per_page = oik_types_get_archive_posts_per_page_for_taxonomy( $query ); } if ( $archive_posts_per_page ) { $query->set( 'posts_per_page', $archive_posts_per_page ); } } else { // Not archive so nothing to do. } } }View on GitHub