Remove Schema from Woocommerce product pages

Remove Schema from Woocommerce product pages

Add this code to your main or child theme functions.php file. 

Decide what data you want removed and use the snippet that allows you to do that.


/**
 * Remove all product structured data.
 */
function ace_remove_product_structured_data( $types ) {
    if ( ( $index = array_search( 'product', $types ) ) !== false ) {
        unset( $types[ $index ] );
    }

    return $types;
}
add_filter( 'woocommerce_structured_data_type_for_page', 'ace_remove_product_structured_data' );

Remove partial product structured data.


 /**
 * Remove partial product structured data.
 */
function ace_remove_partial_product_structured_data( $markup_offer, $product ) {
    $markup_offer = array(
        'availability'  => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
        'url'           => get_permalink( $product->get_id() ),
        'seller'        => array(
            '@type' => 'Organization',
            'name'  => get_bloginfo( 'name' ),
            'url'   => home_url(),
        ),
    );

    return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'ace_remove_partial_product_structured_data', 10, 2 );

Remove partial product structured data.


 /**
 * Remove partial product structured data.
 */
function ace_remove_partial_product_structured_data( $markup, $product ) {
    unset( $markup['aggregateRating'] );

    return $markup;
}
add_filter( 'woocommerce_structured_data_product', 'ace_remove_partial_product_structured_data', 10, 2 );

Remove partial product structured data.


 /**
 * Remove partial product structured data.
 */
function ace_remove_partial_product_structured_data( $markup_offer, $product ) {
    unset( $markup_offer['availability'] );

    return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'ace_remove_partial_product_structured_data', 10, 2 );

Share :

Add New Comment

 Your Comment has been sent successfully. Thank you!   Refresh
Error: Please try again