Created
May 2, 2024 08:54
-
-
Save thegulshankumar/36e33ea42913765255540671feb37338 to your computer and use it in GitHub Desktop.
Remove Date & Time in GeneratePress Comment section
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Place this snippet in the functions.php file or use the Code Snippets plugin without PHP opening tags | |
/* | |
* Concepts behind the solution | |
* Google says: If you've followed the best practices above | |
* and find incorrect dates are being selected, | |
* consider if you can remove or minimize other dates that may appear on the page. | |
* https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for | |
* | |
* Note: It worked for us. | |
*/ | |
if ( ! function_exists( 'generate_comment' ) ) { | |
function generate_comment( $comment, $args, $depth ) { | |
$args['avatar_size'] = apply_filters( 'generate_comment_avatar_size', 50 ); | |
if ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) : ?> | |
<li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>> | |
<div class="comment-body"> | |
<?php esc_html_e( 'Pingback:', 'generatepress' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">', '</span>' ); ?> | |
</div> | |
<?php else : ?> | |
<li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>> | |
<article id="div-comment-<?php comment_ID(); ?>" <?php generate_do_element_classes( 'comment-body', 'comment-body' ); ?>> | |
<footer class="comment-meta"> | |
<?php | |
if ( 0 != $args['avatar_size'] ) { // phpcs:ignore | |
echo get_avatar( $comment, $args['avatar_size'] ); | |
} | |
?> | |
<div class="comment-author-info"> | |
<div <?php generate_do_element_classes( 'comment-author' ); ?>> | |
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?> | |
</div> | |
<?php | |
// Remove the pipe symbol before the "Edit" link | |
$edit_link = get_edit_comment_link( $comment->comment_ID ); | |
if ( $edit_link ) { | |
echo '<span class="edit-link"><a class="comment-edit-link" href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'generatepress' ) . '</a></span>'; | |
} | |
?> | |
</div> | |
<?php if ( '0' == $comment->comment_approved ) : // phpcs:ignore ?> | |
<p class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'generatepress' ); ?></p> | |
<?php endif; ?> | |
</footer> | |
<div class="comment-content" itemprop="text"> | |
<?php | |
/** | |
* generate_before_comment_content hook. | |
* | |
* @since 2.4 | |
*/ | |
do_action( 'generate_before_comment_text', $comment, $args, $depth ); | |
comment_text(); | |
/** | |
* generate_after_comment_content hook. | |
* | |
* @since 2.4 | |
*/ | |
do_action( 'generate_after_comment_text', $comment, $args, $depth ); | |
?> | |
</div> | |
</article> | |
<?php | |
endif; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment