• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Genesis Snippets

A reference for Genesis theme developers

  • Home
  • Archives
  • Search Genesis Snippets

Customize comments HTML output

April 9, 2012 By David Wang

Sometimes you need to customize the HTML output of the WordPress comments_template(). Here’s how to do it in your Genesis child theme.

// First remove the genesis_default_list_comments function
remove_action( 'genesis_list_comments', 'genesis_default_list_comments' );

// Now add our own and specify our custom callback
add_action( 'genesis_list_comments', 'child_default_list_comments' );
function child_default_list_comments() {

	$args = array(
		'type'			=> 'comment',
		'avatar_size'	=> 54,
		'callback'		=> 'child_comment_callback',
	);

	$args = apply_filters( 'genesis_comment_list_args', $args );

	wp_list_comments( $args );

}

// This is where you customize the HTML output
function child_comment_callback( $comment, $args, $depth ) {

	$GLOBALS['comment'] = $comment; ?>

	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
		
		<?php do_action( 'genesis_before_comment' ); ?>
		
		<div class="comment-left">

			<div class="comment-author vcard">
				<?php echo get_avatar( $comment, $size = $args['avatar_size'] ); ?>
				<?php printf( __( '<cite class="fn">%s</cite> <span class="says">%s:</span>', 'genesis' ), get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) ) ); ?>
			</div><!-- end .comment-author -->
	
			<div class="comment-meta commentmetadata">
				<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s', 'genesis' ), get_comment_date(), get_comment_time() ); ?></a>
				<?php edit_comment_link( __( 'Edit', 'genesis' ), g_ent( '&bull; ' ), '' ); ?>
			</div><!-- end .comment-meta -->
			
		</div>
		
		<div class="comment-right">	
	
			<div class="comment-content">
				<?php if ($comment->comment_approved == '0') : ?>
					<p class="alert"><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) ); ?></p>
				<?php endif; ?>
	
				<?php comment_text(); ?>
			</div><!-- end .comment-content -->
	
			<div class="reply">
				<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
			</div>
			
		</div>	

		<?php do_action( 'genesis_after_comment' );

	/** No ending </li> tag because of comment threading */

}

In the example above I split the comment into comment-left and comment-right to display it in a 2 column format. Of course, you could customize it more extensively than that. See also the official StudioPress tutorial on customizing comments. Happy hacking!

Filed Under: Genesis Tagged With: comments

Reader Interactions

Comments

  1. Dom says

    August 25, 2013 at 6:10 pm

    Hi,

    This is amazing. I have actually looking for this for a long time now, and I have found it finally. Looks kinda confusing for me right now, but I will show this to my coder.

    Thanks you!

Primary Sidebar

Brought to you by ClickWP
Buy the Genesis Theme Framework

Who’s behind this?

Hi! I'm David and I'm a big Genesis fan. I've been using it in all my projects and have found it to be super powerful.

I started this site to keep track of all the snippets that I've been using in my projects and so that it's easy for me to find them again instead of digging through my old project files.

Help support this site by buying Genesis with our affiliate links. Thanks!

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 354 other subscribers

Browse Snippets

branding cache comments css custom post type doctype entry footer entry header favicon featured image genesis_custom_loop images internet explorer jetpack loop media menu metabox minify navigation oembed page layouts performance plugin integration post thumbnail shortcode sidebars theme options widget areas widgets WooCommerce WordPress
Everything you need to support your online business
Take WordPress further with the Genesis framework

Copyright © 2025 · Genesis Sample On Genesis Framework · WordPress · Log in