New Landing How can we help? Themeforest Theme Support Joyn Remove date in google snippets.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Posted in: Joyn
  • #227302
    mhote
    Member
    Post count: 394

    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

    #227529
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    You need to contact WordPress Seo support, they are in better position to answer this.
    Hope you understand.

    -Rui

    #235075
    mhote
    Member
    Post count: 394
    This reply has been marked as private.
    #235198
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    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.

    #236671
    mhote
    Member
    Post count: 394

    Worked instantly once re-submitting the index, thank you David!

    #236728
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Great thanks to David for this code snippet.
    Mohammad

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register