-
AuthorPosts
-
November 20, 2019 at 1:16 am #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!
November 22, 2019 at 12:28 pm #1159096I 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:
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.
November 22, 2019 at 3:03 pm #1159176Hie-cat,
Please have a look at the article here:
If you need further assistance please let us know.
Best regards,
VictoriaNovember 22, 2019 at 5:05 pm #1159224Hi 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
November 26, 2019 at 4:07 am #1160174Hi,
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,
IsmaelNovember 26, 2019 at 1:21 pm #1160307Thank you so much for the code! I entered the code in functions.php, but unfortunately the datepublished of the Woocommerce reviews is still there.
“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.
November 28, 2019 at 4:47 am #1160862Hi,
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,
IsmaelNovember 28, 2019 at 1:23 pm #1160956Thank you, I will check this out!
Kind regards,
GersonDecember 1, 2019 at 12:01 am #1161515Hi,
Let us know if you need further assistance.
Best regards,
BasilisDecember 2, 2019 at 12:11 pm #1161816Hi, 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%2FDecember 4, 2019 at 8:08 am #1162481Hi,
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,
IsmaelDecember 4, 2019 at 6:37 pm #1162691Hi 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,
GersonDecember 5, 2019 at 11:19 am #1162883Hi,
Thank you for the update.
Can we access the file server? Please post the FTP login details in the private field.
Best regards,
IsmaelDecember 5, 2019 at 11:36 am #1162893This reply has been marked as private.December 6, 2019 at 5:00 am #1163283Hi,
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,
IsmaelDecember 6, 2019 at 9:48 am #1163326Hi 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.
December 9, 2019 at 4:27 am #1163959Hi,
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,
IsmaelDecember 10, 2019 at 12:07 am #1164244This reply has been marked as private.December 11, 2019 at 8:17 am #1164733Hi,
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,
IsmaelDecember 11, 2019 at 9:27 am #1164756OK, I will try that. Thank you for your time and help, Ismael!
-
AuthorPosts
- You must be logged in to reply to this topic.