Using get_comment_date & get_comment_time In A Custom Comments Loop

When using get_comments or WP_Comment_Query to code your custom comments loop, you can add the date and time using any format strings WordPress.

In this case, we’re using a new WP_Comment_Query to create a custom loop of comments for reviews which output like this :

Comment Date & Time

This example shows both the comment date and comment time however you can use this code to modify both or display the date only for each comment like this:

Comment Date

Demo Video

Shows the comment date displaying for each comment in a custom comments loop. Shows you how to change the comment date format using your WordPress general settings.

Tested using the Genesis Sample child theme by StudioPress however will work in any Genesis child theme.

How To Customize The Code

Download Folder

The download folder contains the custom customments loop you can output using any WordPress or Genesis hook like this :

add_action( 'genesis_after_entry', 'hook_comments_loop' );
function hook_comments_loop() {

if ( have_comments() || get_comments_number( $post_id > 0 ) ) {

echo custom_comments_loop();

}
}

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.