Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1490772

    Hallo Zusammen, bei Woocommerce kann man ja einstellen, wo ein Produkt gezeigt werden soll.
    Im Shop und den Suchergebnissen, Nur im Shop, nur Suchergebnisse oder ausgblendet.
    Leider funktioniert das nicht für die Enfold Suche und bei Ähnlichen Produkten wird es auch angezeigt, wenn man es zb auf ausgeblendet setzt. Ich habe es jetzt mit CSS gelöst, aber vielleicht könnte man das ja mit einem Update in Zukunft mal besser lösen?

    Danke und Gruß KiM

    #1490787

    Hey Blatze,

    Thank you for the inquiry.

    Try to add this code in the functions.php file to adjust the search query for products:

    function ava_pre_get_posts_mod( $query ) {
        if ( ! is_admin() && $query->is_search() && $query->is_main_query() ) {
            if ( class_exists( 'WooCommerce' ) && ( $query->get( 'post_type' ) === 'product' || isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' ) ) {
    
                $meta_query = (array) $query->get( 'meta_query' );
    
                $meta_query[] = array(
                    'key'     => 'catalog_visibility',
                    'value'   => array( 'hidden', 'exclude-from-search' ),
                    'compare' => 'NOT IN'
                );
    
                $query->set( 'meta_query', $meta_query );
            }
        }
    }
    add_action( 'pre_get_posts', 'ava_pre_get_posts_mod', 20 );
    

    Let us know the result.

    Best regards,
    Ismael

    #1490819

    Hi Ismael,

    danke für die schnelle Hilfe, falls dies das ausgeblendete Produkt auch bei ähnliche Produkte und in der Enfold Suche ausblenden sollte, dann funktioniert der Code nicht. Habe es gerade mit einem Produkt getestet und es wird bei beidem noch angezeigt.
    Danke

    Hi Ismael,

    Thanks for your quick help. If this is supposed to hide the hidden product from similar products and the Enfold search, then the code isn’t working. I just tested it with a product and it’s still showing up in both places.
    Thanks

    #1490887

    Hi,

    Thank you for the inquiry.

    The code is supposed to fix the hidden product issue on the search page. If this is not working, we may need to view and access the site to check the issue further. Please provide examples of the hidden products that are not supposed to display on the search page, then include the login details in the private field.

    Best regards,
    Ismael

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