Premium support

Please log in to post in these forums. If you didn't create an account when you purchased, please contact us.

Free support

If you haven't purchased GP Premium, support for the free theme can be found on WordPress.org.

[Resolved] hide comments time metadata

Home Forums Support hide comments time metadata

Tagged: 

This topic contains 16 replies, has 3 voices, and was last updated by  Tom 1 month, 1 week ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #417004

    sg

    Hi , may i know how to hide GP comment times ?

    there is code at

    <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 at %2$s', '1: date, 2: time', 'generatepress' ), get_comment_date(), get_comment_time() ); ?>
    							</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 -->

    how do i adjust this pls. thanks

    #417007

    sg

    update

    #417035

    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 -->
    
    #417047

    sg

    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.

    #417124

    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;
    #417273

    Tom
    Lead Developer

    Thanks 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 🙂

    #417466

    sg

    excellent team work. thanks.

    #417469

    sg

    Sorry lil trouble here.
    i added the code to my code snippets plugins, the page went blank. please advice.

    #417563

    Tom
    Lead Developer

    Did it give you a specific error, or just a white page?

    #417575

    sg

    white page.

    #417582

    Tom
    Lead Developer

    Try 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;
    }
    #417609

    sg

    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 -->
    #417886

    Tom
    Lead Developer

    Did you try the function I posted above for removing the date?

    #417999

    sg

    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.

    #418187

    Tom
    Lead Developer
Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.