pre_get_posts only works when logged in
-
I’m using a plugin to create an issue based publication. The plugin creates a custom taxonomy issuem_issue. I’m trying to filter the category page to only show the active issue (using their built in function get_active_issuem_issue()).
I’m added the following to the theme’s function.php file:
function limit_issuem_taxonomies_to_active_issue( $query ) { if ( is_admin() || !($query->is_main_query()) ){ return; } if ( is_category() ) { if ( function_exists( 'get_active_issuem_issue' ) ) { $tax_query = array( array( 'taxonomy' => 'issuem_issue', 'field' => 'slug', 'terms' => get_active_issuem_issue(), ) ); $query->set( 'tax_query', $tax_query ); } return; } } add_action( 'pre_get_posts', 'limit_issuem_taxonomies_to_active_issue', 1 );
This function works while I’m logged in, but once I log out, the category page shows all articles in all the issues, not just the current active issue.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘pre_get_posts only works when logged in’ is closed to new replies.