Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #1158325

    Hello!

    I have an Enfold site with Woocommerce. Google shows all products in search very nicely, but also with a date. It seems to take the date a review of a product was made. Very strange choice I think. It also takes space, the short description space is shorter then. So, I would like to have it removed in the search results.

    Visitors don’t see this date on the site (as I have it as display no show), but it is still hidden in the source code. Google takes the info from “datePublished” of Woocommerce reviews.

    Any suggestion to take out this datePublished info so it doesn’t show in Google? Maybe with some filter snippet code in functions.php? Thanks!

    #1159096

    I also asked RankMath wether they know how to get rid of the Woocommerce review date. Their answer:

    “That is not added by Rank Math. You have to use a WooCommerce specific filter to remove the date from your WooCommerce reviews. The Best person to help with this is your theme provider. Please get in touch with them and let us know if anything is needed from our end.”

    This is a product page: Product page Woocommerce with Enfold

    This is how it look in Google search results: Google search

    I would like to remove the (Woocommerce review) date from the Google search results. It doesn’t make any sense that a review date is shown in the results.

    Thank you!

    • This reply was modified 5 years, 1 month ago by e-cat.
    #1159176

    Hie-cat,

    Please have a look at the article here:

    How can I modify Structured Data from WooCommerce products?

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1159224

    Hi Victoria,

    Is there no other (simpler and cheaper) solution to remove the Woocommerce Review Datepublished from the Schema?

    I would prefer not to buy another plugin only to remove Woocommerce Schema fully and to set up all new Schema for products

    The current Woocommerce Schema is fine by me, except for the ridiculous publishing date of the oldest product review.

    Could I add a code snippet / filter in functions.php? To filter out this Datepublished?

    Kind regards, Gerson

    #1160174

    Hi,

    Thank you for the update.

    You can add the following snippet in the functions.php file to remove the default product review data generator, then add it again without the datePublished info.

    function ava_remove_output_structured_data() {
    	remove_action( 'woocommerce_review_meta', array( WC()->structured_data, 'generate_review_data' ), 20 );
    }
    add_action( 'init', 'ava_remove_output_structured_data' );
    
    function avia_generate_review_data( $comment ) {
    	$markup                  = array();
    	$markup['@type']         = 'Review';
    	$markup['@id']           = get_comment_link( $comment->comment_ID );
    	// $markup['datePublished'] = get_comment_date( 'c', $comment->comment_ID );
    	$markup['description']   = get_comment_text( $comment->comment_ID );
    	$markup['itemReviewed']  = array(
    		'@type' => 'Product',
    		'name'  => get_the_title( $comment->comment_post_ID ),
    	);
    
    	// Skip replies unless they have a rating.
    	$rating = get_comment_meta( $comment->comment_ID, 'rating', true );
    
    	if ( $rating ) {
    		$markup['reviewRating'] = array(
    			'@type'       => 'Rating',
    			'ratingValue' => $rating,
    		);
    	} elseif ( $comment->comment_parent ) {
    		return;
    	}
    
    	$markup['author'] = array(
    		'@type' => 'Person',
    		'name'  => get_comment_author( $comment->comment_ID ),
    	);
    
    	WC()->structured_data->set_data( apply_filters( 'woocommerce_structured_data_review', $markup, $comment ) );
    }
    add_action( 'woocommerce_review_meta', 'avia_generate_review_data', 20 );
    

    Best regards,
    Ismael

    #1160307

    Thank you so much for the code! I entered the code in functions.php, but unfortunately the datepublished of the Woocommerce reviews is still there.

    Sample product page:

    “review”:[{“@type”:”Review”,”@id”:”https:\/\/popcards.nl\/kaart\/wenskaart-hollandse-fiets-met-rode-tulpen\/#li-comment-64″,”description”:”Hollandser dan dit kan je niet krijgen. Leuk met die bloemetjes en dat mandje. En veel detail! Echt leuk.”,“datePublished”:”2018-11-10 11:21:53″,”reviewRating”:{“@type”:”Rating”,”ratingValue”:5},”author”:{“@type”:”Person”,”name”:”Dani\u00eblle”,”url”:””}}]

    You can see it via https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fpopcards.nl%2Fkaart%2Fwenskaart-hollandse-fiets-met-rode-tulpen%2F as well.

    Maybe the removal part of the code is not correct?

    Kind regards, Gerson

    • This reply was modified 5 years ago by e-cat.
    #1160862

    Hi,

    Thank you for the update.

    Yes, the hook removal doesn’t seem to work. Please replace the whole snippet with this filter instead.

    add_filter('woocommerce_structured_data_review', function($markup, $comment) {
    	unset($markup['datePublished']);
    	return $markup;
    }, 10, 2);

    Best regards,
    Ismael

    #1160956

    Thank you, I will check this out!

    Kind regards,
    Gerson

    #1161515

    Hi,

    Let us know if you need further assistance.

    Best regards,
    Basilis

    #1161816

    Hi, I added the snippet but the DatePublished is still there. So the filter doesn’t work unfortunately.

    You can also see the DatePublished in the structured data testing tool:
    https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fpopcards.nl%2Fkaart%2Fwenskaart-hollandse-fiets-met-rode-tulpen%2F

    #1162481

    Hi,

    Thank you for the update.

    The filter works properly on our installation. Did you remove the browser cache before doing the test again? Is the html minified? It’s possible that the tool is testing a cached version of the markup.

    Best regards,
    Ismael

    #1162691

    Hi Ismael,

    Yes, the cache is removed etc. I use WP Rocket and cleared everything. The DatePublished is still there.

    Even when I remove the following sentence in class-wc-structured-data.php, the DatePublished of Woocommerce reviews is still being generated. It is driving me nuts!

    public function generate_review_data( $comment ) {
    $markup = array();
    $markup[‘@type’] = ‘Review’;
    $markup[‘@id’] = get_comment_link( $comment->comment_ID );
    $markup[‘datePublished’] = get_comment_date( ‘c’, $comment->comment_ID ); <= Removing this line doesn’t help either!
    $markup[‘description’] = get_comment_text( $comment->comment_ID );

    from class-wc-structured-data.php, the DatePublished of Woocommerce reviews is still being generated. It is driving me nuts!

    Kind regards,
    Gerson

    #1162883

    Hi,

    Thank you for the update.

    Can we access the file server? Please post the FTP login details in the private field.

    Best regards,
    Ismael

    #1162893
    This reply has been marked as private.
    #1163283

    Hi,

    Thank you for the update.

    Where did you add the filter? We can’t find it in the functions.php file, so we added it back. It doesn’t work yet because WP Rocket minified or compressed the html. Please disable WP Rocket temporarily, then try to check the page again. Or post a login account to the WP dashboard so that we can test it.

    Best regards,
    Ismael

    #1163326

    Hi Ismael,

    I added it via Code Snippets, so the code was already there. I disabled WP Rocket temporarily and checked again. All datePublished dates are still there, no change. The snippet doesn’t seem to remove the Woocommerce datePublished reviews. Maybe the filter is targeting the wrong file?

    I also deactived many other Woocommerce related plugins, but no change there as well. Hard issue to tackle! Don’t understand it.

    Kind regards, Gerson

    • This reply was modified 5 years ago by e-cat.
    #1163959

    Hi,

    Thank you for the update.

    Can you provide a login account for the WP dashboard? We have to check the settings before doing the test data test again. Please post the login details in the private field.

    Best regards,
    Ismael

    #1164244
    This reply has been marked as private.
    #1164733

    Hi,

    Thank you for the update.

    We can’t make the filter work in your installation as it works on our own. As you can see in the screenshot below, the “datePublished” key is removed from the $markup array.

    // https://imgur.com/a/kDYDXCl

    Please try to deactivate the WooCommerce extensions temporarily. Or try to deactivate all plugins except for WooCommerce.

    Best regards,
    Ismael

    #1164756

    OK, I will try that. Thank you for your time and help, Ismael!

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