Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1050974

    Hi there!

    Products I’ve hidden via Woocommerce are still appearing in search results and in the left/right arrows on individual products, can they be hidden from these? Using a snippet of functions code in another thread about the same issue I’ve hidden the hidden products from the ajax search, but if you go to the search results page then hidden products still appear, and they still appear in the left/right arrows.

    #1051727

    Hey chartinboy,

    Thank you for using Enfold.

    You can use this filter to remove hidden products from the search results page.

    
    if ( ! function_exists( 'pre_get_posts_remove_hidden_product' ) ){
      function pre_get_posts_remove_hidden_product( $query = false ) {
        if(!is_admin() && is_search()){
          $query->set( 'meta_query', array(
            'relation' => 'OR',
            array(
              'key' => '_visibility',
              'value' => 'hidden',
              'compare' => 'NOT EXISTS',
            ),
            array(
              'key' => '_visibility',
              'value' => 'hidden',
              'compare' => '!=',
            ),
          ));
        }
      }
    }
    add_action( 'pre_get_posts', 'pre_get_posts_remove_hidden_product' );

    Unfortunately, you can’t exclude those products from the side navigation.

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.