Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Joyn › Remove date in google snippets.
New Landing › How can we help? › Themeforest Theme Support › Joyn › Remove date in google snippets.
- This topic has 5 replies, 4 voices, and was last updated 8 years by Mohammad – SUPPORT.
-
Posted in: Joyn
-
November 10, 2015 at 5:50 am #227302
Hi,
I am trying to remove the dates on google snippet but it is not working correctly.
I already tried by adding below code to functions.php.
add_filter( 'wpseo_show_date_in_snippet_preview', false);
Also i found these code somewhere. Do you think this will work ?
function remove_post_dates() { add_filter('the_time', '__return_false'); add_filter('get_the_time', '__return_false'); add_filter('the_modified_time', '__return_false'); add_filter('get_the_modified_time', '__return_false'); add_filter('the_date', '__return_false'); add_filter('get_the_date', '__return_false'); add_filter('the_modified_date', '__return_false'); add_filter('get_the_modified_date', '__return_false'); add_filter('get_comment_date', '__return_false'); add_filter('get_comment_time', '__return_false'); } add_action('loop_start', 'remove_post_dates');
This code might make lots of changes. So i want to make sure first.
Can you please help me to fix this.Best Regards
November 10, 2015 at 4:55 pm #227529Hi,
You need to contact WordPress Seo support, they are in better position to answer this.
Hope you understand.-Rui
December 12, 2015 at 7:03 am #235075This reply has been marked as private.December 14, 2015 at 11:13 am #235198Hi,
To remove the date from the SERP’s, please active your child theme. Inside the child theme folder find
functions.php
. Inside this, copy and paste this:/* POST DETAIL META ================================================== */ if ( ! function_exists( 'sf_post_detail_meta' ) ) { function sf_post_detail_meta() { global $post; $post_title = get_the_title(); $post_date = get_the_date(); $post_date_str = get_the_date('Y-m-d'); $post_image = get_post_thumbnail_id(); $image_meta = array(); $post_image_url = $post_image_alt = ""; if ( $post_image != "" ) { $post_image_meta = sf_get_attachment_meta( $post_image ); if ( isset($post_image_meta) ) { $post_image_alt = esc_attr( $post_image_meta['alt'] ); } $post_image_url = wp_get_attachment_url(get_post_thumbnail_id()); } ?> <div class="article-meta hide"> <div itemprop="headline"><?php echo $post_title; ?></div> <?php if ( $post_image != "" ) { ?> <img itemprop="image" src="<?php echo $post_image_url; ?>" alt="<?php echo $post_image_alt; ?>"/> <?php } ?> </div> <?php } } add_action( 'sf_post_article_start', 'sf_post_detail_meta', 0 );
This will remove the line
<time itemprop="datePublished" datetime="<?php echo $post_date_str; ?>"><?php echo $post_date; ?></time>
this is what Google uses to output the date.However: Google will only update their SERP’s without the date when they next crawl your site’s pages, this could take weeks or months to reflect in Google’s index.
Thanks.
December 20, 2015 at 10:12 am #236671Worked instantly once re-submitting the index, thank you David!
December 21, 2015 at 6:41 am #236728Hi,
Great thanks to David for this code snippet.
Mohammad -
Posted in: Joyn
You must be logged in and have valid license to reply to this topic.