• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Callia Web

Callia Web

Websites - Design with Purpose

  • Home
  • Websites
  • Support
  • Our Work
  • About
  • Contact

Customising comment date in Genesis 2.2

3 Oct 2015

In the Genesis Slack Group ( #code-snippets channel) Brian Bourn mentioned a new filter in Genesis 2.2 that allows you to customise the comment meta data.

And right there on lines 317 – 333 in the genesis/lib/structure/comments.php file is:

/**
* Allows developer to control whether to print the comment date.
*
* @since 2.2.0
*
* @param boolean $comment_date Whether to print the comment date
* @param string  $post_type    The current post type
*/
$comment_date = apply_filters( 'genesis_show_comment_date', true, get_post_type() );

if ( $comment_date ) {
	printf( '<p %s>', genesis_attr( 'comment-meta' ) );
	printf( '<time %s>', genesis_attr( 'comment-time' ) );
	printf( '<a href="%s" %s>', esc_url( get_comment_link( $comment->comment_ID ) ), genesis_attr( 'comment-time-link' ) );
	echo    esc_html( get_comment_date() ) . ' ' . __( 'at', 'genesis' ) . ' ' . esc_html( get_comment_time() );
	echo    '</a></time></p>';
}

So if $comment_date is set to true, the comment dates are output and if its false, they don\’t.

Therefore to simply remove the comment dates from your comments you can use the WordPress __return_false function and put the following line in your functions file:

// Remove the date and time on comments in Genesis child themes
add_filter( 'genesis_show_comment_date', '__return_false' );

And your comments go from this

Genesis comments with date and time

to this

Genesis comments without date and time

(The edit link is showing because I was logged in when I created these screenshots)

The reason I was excited to hear about this new filter is because on my own web design agency\’s website I wanted to remove the time from my comments (and keep the date) but to do so I had use the genesis_comment_list_args filter to use my own custom version of the genesis_html5_comment_callback function. And that\’s quite a few lines of code!

But now with this new filter in Genesis 2.2, there is a neater way:

You can also view this code on github.

add_filter( 'genesis_show_comment_date', 'jmw_show_comment_date_with_link' );
/**
 * Show Comment Date with link but without the time
 *
 * Stop the output of the Genesis core comment dates and outputs comments with date and link only.
 * The genesis_show_comment_date filter was introduced in Genesis 2.2 (will not work with older versions)
 *
 * @author Jo Waltham
 * @link http://www.jowaltham.com/customising-comment-date-genesis/
 *
 * @param boolean $comment_date Whether to print the comment date or not
 * @return boolean Whether to print the comment date or not
 */
function jmw_show_comment_date_with_link( $comment_date ) {

	printf('<p %s><time %s><a href="%s" %s>%s</a></time></p>',
		genesis_attr( 'comment-meta' ),
		genesis_attr( 'comment-time' ),
		esc_url( get_comment_link( get_comment_ID() ) ),
		genesis_attr( 'comment-time-link' ),
		esc_html( get_comment_date() )
	);

	// Return false so that the parent function doesn't output the comment date, time and link
	return false;
}

Which makes the comments look like this:

Genesis comments with just the date and no time

And finally, the reason why this topic came up in the slack channel in the first place is that Paal wanted to show only the date without the link. So one quick further customisation …

(View this code on github)

add_filter( 'genesis_show_comment_date', 'jmw_show_comment_date_only' );
/**
 * Show date on comments without time or link
 *
 * Stop the output of the Genesis core comment dates and outputs comments with date only
 * The genesis_show_comment_date filter was introduced in Genesis 2.2 (will not work with older versions)
 *
 * @author Jo Waltham
 * @link http://www.jowaltham.com/customising-comment-date-genesis/
 *
 * @param boolean $comment_date Whether to print the comment date or not
 * @return boolean Whether to print the comment date or not
 */
function jmw_show_comment_date_only( $comment_date ) {

	printf('<p %s><time %s>%s</time></p>',
		genesis_attr( 'comment-meta' ),
		genesis_attr( 'comment-time' ),
		esc_html( get_comment_date() )
	);

	// Return false so that the parent function doesn't output the comment date, time and link
	return false;
}

You get this:

Genesis comments with date with no link

I love Genesis filters ๐Ÿ™‚

Please note this filter will only work if you are using Genesis 2.2 or later and a HTML5 theme.

Featured Image: Photo by Ella Olsson on Unsplash

Share this post:

Share on FacebookShare on LinkedInShare on E-mailShare on WhatsApp

About Jo Waltham

Jo Waltham is the founder of Callia Web and is passionate about helping people with their websites.

Liked this post? Subscribe to get our next post direct to your inbox.


Previous Post:Sourcing images for your WordPress blog
Next Post:Optimise image size, accessibility and layout in WordPressred brick wall, orange door and bicycle

Reader Interactions

Comments

  1. Paal Joachim

    3 Oct 2015 at 2:51 pm

    Hi Jo

    Thank you very much for creating this article!
    I will add your last code snippet (and add your article as a resource) to my own article on customizing the comments section in a Genesis child theme.

    Have a great weekend!

    Reply
    • Jo Waltham

      3 Oct 2015 at 9:28 pm

      You’re welcome! I just need to implement this on my own site now.

      Reply
  2. Mike Hemberger

    3 Oct 2015 at 3:08 pm

    Jo, excellent write up. I saw Brian mention it on Slack but haven’t had time to try. You just saved us some legwork in trying out this filter. Thanks!

    Reply
    • Jo Waltham

      3 Oct 2015 at 9:28 pm

      Thanks Mike.

      Reply
  3. Sandee

    3 Oct 2015 at 3:10 pm

    Thank you for your work on this on, Jo! I can see where this will come in very handy for a few projects. Adding this code to my saved snippets, for sure!

    Reply
    • Jo Waltham

      3 Oct 2015 at 9:29 pm

      One of the reasons I wrote it up, so it’s handy for when I need it too!

      Reply
  4. Davinder Singh Kainth

    4 Oct 2015 at 4:22 am

    That’s handy. Thanks for sharing Jo!

    Reply
    • Jo Waltham

      4 Oct 2015 at 2:58 pm

      You’re welcome!

      Reply
  5. Chinmoy Paul

    10 Oct 2015 at 7:08 am

    Hi

    I am trying your code in my upcoming theme. I am getting “Notice” error from this line esc_url( get_comment_link( $comment->comment_ID ) ),

    Thanks
    Chinmoy

    Reply
    • Jo Waltham

      10 Oct 2015 at 6:54 pm

      Hi Chinmoy

      Oops that will be because $comment is not defined in or passed to this function.

      As we only need the ID I’ve updated the gist to replace the line
      esc_url( get_comment_link( $comment->comment_ID ) ),

      with
      esc_url( get_comment_link( get_comment_ID() ) ),

      Cheers
      Jo

      Reply
      • Chinmoy Paul

        10 Oct 2015 at 6:59 pm

        Actually Genesis is already using the global variable. I used that variable. My theme have extra theme options. So I modified your code. But this tut was very helpful for me.

        Thank you.

        Reply
  6. Carlo

    11 Oct 2015 at 12:56 am

    Hi Jo. I like the way you changed it to remove the time but keep the date. It should also be noted that this filter only works with HTML5 child themes, even if the parent theme is updated to 2.2.0 or newer.

    Reply
    • Jo Waltham

      11 Oct 2015 at 1:57 pm

      Thanks Carlo, I shall amend the text to point that out.

      Reply
  7. Hitesh Bhasin

    28 Jun 2016 at 12:10 pm

    Hello, Please help me. I want to remove the dates altogether for genesis comments. I added the below code but the dates are still showing. my theme is Genesis news theme and it is HTML5 compliant.

    add_filter( ‘genesis_show_comment_date’, ‘__return_false’ );

    Kindly help

    Reply
    • Jo Waltham

      28 Jun 2016 at 8:28 pm

      Hi Hitesh

      Are you using Genesis 2.2 or later? Are you sure your theme is using enabled for HTML5 – ie you are using News Pro theme, not News theme.

      Is this issue on your website marketing91.com? Because this website using the XHTML News theme and this filter will not work with this theme as it is not HTML5.

      Reply
  8. Mike Hemberger

    19 Jul 2016 at 2:10 pm

    Thanks Jo! Was digging through Genesis core (and somehow missed this filter). I googled for a min and your post came up. Exactly what I needed today. Thanks for being awesome, as usual. ๐Ÿ˜‰

    Reply
    • Jo Waltham

      19 Jul 2016 at 3:51 pm

      Haha thanks Mike, glad to help.

      Reply
  9. Regev

    30 Jul 2016 at 8:25 pm

    You. Are. Awesome.
    THANKS!

    Reply
  10. Shaan Nicol

    24 Jan 2017 at 4:19 pm

    I was looking to re-order the comment field to have the date before the author, looks like this will do the trick, thanks Jo!

    Reply
  11. Keller

    7 May 2017 at 9:24 am

    Thank you so much this worked for me and made my comments styling so much cleaner.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to get started?

Get in touch

Ask Callia Web’s AI

Contact us

Telephone: 01672 666001

Email: hello@calliaweb.co.uk

Quick links

Websites

Our work

Testimonials

About

Blog

Popular posts

Using headings in WordPress

Accessibility basics

Image sizes and aspect ratios

Making images equal size

Beginner’s guide to Analytics

Legal

Privacy policy / Cookie policy

Terms of service

Company number: 08316519

Registered address: Bowman House, Royal Wootton Bassett, Wiltshire, SN4 7DB

Copyright © 2025 ยท Callia Web Ltd ยท All Rights Reserved