How to hide published date from search engines ?

Home Forums ColorMag Free How to hide published date from search engines ?

This topic contains 23 replies, has 9 voices, and was last updated by  overallmotivation 6 days, 6 hours ago.

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #1821571

    Bishal Napit
    Moderator

    @overallmotivation

    Can you let us know about what you are trying to do so that we could help you onto it? Also, the code from those days and now should get changed. So, maybe those are placed in other places now. Hope you have got it. Thanks.

    #1821578

    overallmotivation
    Participant

    Thanks for the reply. I had hide published date from blog posts from the css code mentioned in your support forum. But I want to hide posted date from search engines. Please guide me how to hide dates from search engines engi

    #1821829

    Bishal Napit
    Moderator

    @overallmotivation

    For that, maybe create the child theme, and then, duplicate the colormag_entry_meta() function and then, remove the display of the published date from there and check once? By doing so, it should work out. And that code resides in ‘inc/functions.php’ file of the theme. Thanks.

    #1822339

    overallmotivation
    Participant

    I have following code copied from fuctions.php should I paste this whole code; please tell me after pasting in child theme which part to delete.

    if ( ! function_exists( 'colormag_entry_meta' ) ) :
    	/**
    	 * Shows meta information of post.
    	 */
    	function colormag_entry_meta() {
    		if ( 'post' == get_post_type() ) :
    			echo '<div class="below-entry-meta">';
    			?>
    
    			<?php
    			$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    			if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    				$time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
    			}
    			$time_string = sprintf( $time_string,
    				esc_attr( get_the_date( 'c' ) ),
    				esc_html( get_the_date() ),
    				esc_attr( get_the_modified_date( 'c' ) ),
    				esc_html( get_the_modified_date() )
    			);
    			printf( __( '<span class="posted-on"><a href="%1$s" title="%2$s" rel="bookmark"><i class="fa fa-calendar-o"></i> %3$s</a></span>', 'colormag' ),
    				esc_url( get_permalink() ),
    				esc_attr( get_the_time() ),
    				$time_string
    			); ?>
    
    			<span class="byline">
    				<span class="author vcard">
    					<i class="fa fa-user"></i>
    					<a class="url fn n"
    					   href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
    					   title="<?php echo get_the_author(); ?>"><?php echo esc_html( get_the_author() ); ?>
    					</a>
    				</span>
    			</span>
    
    			<?php
    			if ( ! post_password_required() && comments_open() ) { ?>
    				<span class="comments"><?php comments_popup_link( __( '<i class="fa fa-comment"></i> 0 Comments', 'colormag' ), __( '<i class="fa fa-comment"></i> 1 Comment', 'colormag' ), __( '<i class="fa fa-comments"></i> % Comments', 'colormag' ) ); ?></span>
    			<?php }
    			$tags_list = get_the_tag_list( '<span class="tag-links"><i class="fa fa-tags"></i>', __( ', ', 'colormag' ), '</span>' );
    			if ( $tags_list ) {
    				echo $tags_list;
    			}
    
    			edit_post_link( __( 'Edit', 'colormag' ), '<span class="edit-link"><i class="fa fa-edit"></i>', '</span>' );
    
    			echo '</div>';
    		endif;
    	}
    endif;
    
    

    thanks

    #1822378

    Nitu Shrestha
    Moderator

    @overallmotivation

    You can remove the below Code and check:

    <?php
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
      $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
    }
    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( 'c' ) ),
    esc_html( get_the_modified_date() ));
    printf( __( '<span class="posted-on"><a href="%1$s" title="%2$s" rel="bookmark"><i class="fa fa-calendar-o"></i> %3$s</a></span>', 'colormag' ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    $time_string); 
    ?>

    Thanks.

    #1823227

    overallmotivation
    Participant

    The above code which I copied of fuctions.php and pasting in child theme functions.php & deleting the above code it gives error uploading.

    Pasted after this code.

    <?php 
    	 add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    	 function my_theme_enqueue_styles() { 
     		  wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 
     		  }
    
    ?>
    
    

    Thanks

    #1823347

    Bishal Napit
    Moderator

    @overallmotivation

    Can you let us know about what error is shown up when trying to use that code within your site, as well as your final code too? Thanks.

    #1824817

    overallmotivation
    Participant

    Error was Your PHP code changes were rolled back due to an error on line 38 of file wp-content/themes/colormagchildtheme/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘endif’ (T_ENDIF), expecting end of file.

    And final code in child theme functions.php was this

    <?php 
    	 add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    	 function my_theme_enqueue_styles() { 
     		  wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 
     		  }
    
    ?>
    if ( ! function_exists( 'colormag_entry_meta' ) ) :
    	/**
    	 * Shows meta information of post.
    	 */
    	function colormag_entry_meta() {
    		if ( 'post' == get_post_type() ) :
    			echo '<div class="below-entry-meta">';
    			?>
    			<span class="byline">
    				<span class="author vcard">
    					<i class="fa fa-user"></i>
    					<a class="url fn n"
    					   href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
    					   title="<?php echo get_the_author(); ?>"><?php echo esc_html( get_the_author() ); ?>
    					</a>
    				</span>
    			</span>
    
    			<?php
    			if ( ! post_password_required() && comments_open() ) { ?>
    				<span class="comments"><?php comments_popup_link( __( '<i class="fa fa-comment"></i> 0 Comments', 'colormag' ), __( '<i class="fa fa-comment"></i> 1 Comment', 'colormag' ), __( '<i class="fa fa-comments"></i> % Comments', 'colormag' ) ); ?></span>
    			<?php }
    			$tags_list = get_the_tag_list( '<span class="tag-links"><i class="fa fa-tags"></i>', __( ', ', 'colormag' ), '</span>' );
    			if ( $tags_list ) {
    				echo $tags_list;
    			}
    
    			edit_post_link( __( 'Edit', 'colormag' ), '<span class="edit-link"><i class="fa fa-edit"></i>', '</span>' );
    
    			echo '</div>';
    		endif;
    	}
    endif;

    Please suggest.

    #1825859

    overallmotivation
    Participant

    Hello Team,

    Please update on above query.

    Thanks

Viewing 9 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic.