Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('pre_get_posts', function ($query) {
- if (!$query->is_main_query()) {
- return;
- }
- if (!is_admin() && (is_shop() || is_product_category() || is_product_taxonomy() || is_product_tag() || function_exists('wcfm_is_store_page') && wcfm_is_store_page())) {
- $tax_query = $query->get('tax_query') ? $query->get('tax_query') : array();
- $tax_query[] = array(
- 'taxonomy' => 'product_visibility',
- 'field' => 'slug',
- 'terms' => 'archived',
- 'operator' => 'NOT IN',
- );
- $query->set('tax_query', $tax_query);
- }
- });
- add_filter( 'found_posts', function( $found_posts, $query ) {
- if ( ! is_admin() && $query->is_main_query() && ( $query->is_shop() || $query->get('post_type') === 'product' && $query->is_archive() || (function_exists('wcfm_is_store_page') && wcfm_is_store_page()) ) ) {
- $actual_post_count = count( $query->posts );
- return $actual_post_count;
- }
- return $found_posts;
- }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement