- This topic has 16 replies, 3 voices, and was last updated 7 years, 3 months ago by
Tom.
-
AuthorPosts
-
November 6, 2017 at 4:27 am #417004November 6, 2017 at 4:28 am #417007
sg
update
November 6, 2017 at 6:05 am #417035Andrew
This should work to get rid of the comment time and move the separator bars (|) around so they look right still. It does remove the comment permalink. You would need to update and use this in a child theme to make sure it does not get overwritten in the next theme update.
<div class="entry-meta comment-metadata"> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link"> ', ' | </span>' ); ?> <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<span class="reply">', 'after' => '</span>', ) ) ); ?> </div><!-- .comment-metadata -->
November 6, 2017 at 6:19 am #417047sg
Thanks Andrew,
Do i copy the file template-tags.php to 1. childtheme/inc/template-tags.php OR 2.childtheme/template-tags.php ?
also i just need to get rid of the time, i still need to keep the dates.
November 6, 2017 at 7:20 am #417124Andrew
Well I’m sorry, I told you wrong on both counts. Since it’s in the inc folder copying to the child theme does not help! But since Tom is great about letting your override you can create your own comment function by pasting this into your child theme’s functions.php. This also keeps the date and just removes the time as you originally asked!
/* Comment Template to Just Show Date */ 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 _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(); ?>" class="comment-body"> <footer class="comment-meta"> <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> <div class="comment-author-info"> <div class="comment-author vcard"> <?php printf( '<cite class="fn">%s</cite>', get_comment_author_link() ); ?> </div><!-- .comment-author --> <div class="entry-meta comment-metadata"> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <time datetime="<?php comment_time( 'c' ); ?>"> <?php printf( _x( '%1$s', '1: date', 'generatepress' ), get_comment_date() ); ?> </time> </a> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' ); ?> <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<span class="reply">| ', 'after' => '</span>', ) ) ); ?> </div><!-- .comment-metadata --> </div><!-- .comment-author-info --> <?php if ( '0' == $comment->comment_approved ) : ?> <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'generatepress' ); ?></p> <?php endif; ?> </footer><!-- .comment-meta --> <div class="comment-content"> <?php comment_text(); ?> </div><!-- .comment-content --> </article><!-- .comment-body --> <?php endif; } endif;
November 6, 2017 at 10:05 am #417273Tom
Lead DeveloperLead DeveloperThanks for helping, Andrew! I adjusted your code a bit to include
function_exists()
, which will prevent any errors when two functions are named the same 🙂November 6, 2017 at 4:57 pm #417466sg
excellent team work. thanks.
November 6, 2017 at 5:11 pm #417469sg
Sorry lil trouble here.
i added the code to my code snippets plugins, the page went blank. please advice.November 6, 2017 at 10:59 pm #417563Tom
Lead DeveloperLead DeveloperDid it give you a specific error, or just a white page?
November 6, 2017 at 11:13 pm #417575sg
white page.
November 6, 2017 at 11:34 pm #417582Tom
Lead DeveloperLead DeveloperTry this code instead:
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 _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(); ?>" class="comment-body"> <footer class="comment-meta"> <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> <div class="comment-author-info"> <div class="comment-author vcard"> <?php printf( '<cite class="fn">%s</cite>', get_comment_author_link() ); ?> </div><!-- .comment-author --> <div class="entry-meta comment-metadata"> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' ); ?> <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<span class="reply">| ', 'after' => '</span>', ) ) ); ?> </div><!-- .comment-metadata --> </div><!-- .comment-author-info --> <?php if ( '0' == $comment->comment_approved ) : ?> <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'generatepress' ); ?></p> <?php endif; ?> </footer><!-- .comment-meta --> <div class="comment-content"> <?php comment_text(); ?> </div><!-- .comment-content --> </article><!-- .comment-body --> <?php endif; } }
Alternatively, you can just hide it with CSS:
.comment-metadata { display: none; }
November 7, 2017 at 12:52 am #417609sg
the
.comment-metadata { display: none; }
will hide all the date and time. i just need to hide the time.
On the other needs, pls advice how to remove the link to webpage .
code found :
<div class="comment-author vcard"> <?php printf( '<cite class="fn">%s</cite>', get_comment_author_link() ); ?> </div><!-- .comment-author -->
November 7, 2017 at 8:44 am #417886Tom
Lead DeveloperLead DeveloperDid you try the function I posted above for removing the date?
November 7, 2017 at 11:39 am #417999sg
Hi tom, removing date is solved, the code is working, thanks.
i would like to remove the link to the website from user name .
pls advice. thanks.November 7, 2017 at 9:04 pm #418187Tom
Lead DeveloperLead DeveloperPerhaps a plugin like this would help: https://wordpress.org/plugins/hide-wp-comment-author-link/
-
AuthorPosts
- You must be logged in to reply to this topic.