Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20269
    Websiteguy
    Member

    Hi

    How can I change the comments “Post Author” to “Author” in my child theme.

    Thanks

    #20276
    Sakin
    Keymaster

    @Websiteguy: You can simply add the following php code in your child theme functions.php file

    /**
     * Template for comments and pingbacks.
     *
     * Used as a callback by wp_list_comments() for displaying the comments.
     */
    function catcheverest_comment( $comment, $args, $depth ) {
    	$GLOBALS['comment'] = $comment;
    	switch ( $comment->comment_type ) :
    		case 'pingback' :
    		case 'trackback' :
    		// Display trackbacks differently than normal comments.
    	?>
    	<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
    		<p><?php _e( 'Pingback:', 'catcheverest' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'catcheverest' ), '<span class="edit-link">', '</span>' ); ?></p>
    	<?php
    			break;
    		default :
    		// Proceed with normal comments.
    		global $post;
    	?>
    	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    		<article id="comment-<?php comment_ID(); ?>" class="comment">
    			<header class="comment-meta comment-author vcard">
    				<?php
    					echo get_avatar( $comment, 44 );
    					printf( '<cite class="fn">%1$s %2$s</cite>',
    						get_comment_author_link(),
    						// If current post author is also comment author, make it known visually.
    						( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Author', 'catcheverest' ) . '</span>' : ''
    					);
    					printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
    						esc_url( get_comment_link( $comment->comment_ID ) ),
    						get_comment_time( 'c' ),
    						/* translators: 1: date, 2: time */
    						sprintf( __( '%1$s at %2$s', 'catcheverest' ), get_comment_date(), get_comment_time() )
    					);
    				?>
    			</header><!-- .comment-meta -->
    
    			<?php if ( '0' == $comment->comment_approved ) : ?>
    				<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'catcheverest' ); ?></p>
    			<?php endif; ?>
    
    			<section class="comment-content comment">
    				<?php comment_text(); ?>
    				<?php edit_comment_link( __( 'Edit', 'catcheverest' ), '<p class="edit-link">', '</p>' ); ?>
    			</section><!-- .comment-content -->
    
    			<div class="reply">
    				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'catcheverest' ), 'after' => ' <span>&darr;</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    			</div><!-- .reply -->
    		</article><!-- #comment-## -->
    	<?php
    		break;
    	endswitch; // end comment_type check
    }
    #20310
    Websiteguy
    Member

    Works great! Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Change comment "Post Author" to "Author" in child theme.’ is closed to new replies.