Using Simple Hooks to remove comment date

Community Forums Forums Design Tips and Tricks Using Simple Hooks to remove comment date

This topic is: not resolved

Tagged: , , ,

This topic contains 10 replies, has 4 voices, and was last updated by  braddalton 2 years, 3 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • #25815


    Hi, is there anyway to use Simple hooks plug in to remove the dates and time from comments. If not, where is the code in CSS File to remove it?

    Using metro theme



    This CSS code will hide the date and time:

    .comment-meta {
    display: none;

    Paste it at the end of your child themes style.css file.



    Brad’s solution is probably the best way to solve your problem, but it is a teeny bit hacky in that it leaves html on your page that you really don’t want.

    In case anyone is interested, here is a complicated (but cleaner) way to implement this.

    In your functions.php file  add_filter('genesis_comment_list_args', 'my_custom_comment_list_args'). Then define the function:

    function my_custom_comment_list_args($args){

    $args = array(
    'callback' = 'custom_comment_callback_no_date',



    Define a function like this in functions.php (it is a copy of the callback that genesis uses, only without the comment date/time):

    function custom_comment_callback_no_date( $comment, $args, $depth ) {

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

    <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">

    <?php do_action( 'genesis_before_comment' ); ?>

    <div class="comment-header">
    <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-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'] ) ) ); ?>

    <?php do_action( 'genesis_after_comment' );

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




    Worked a treat. Thank you very much Brad



    Sorry Stacy, did not see your reply because was working on the style sheet.

    Unfortunately all of what you said just went totally straight over the top of my head. I am novice when it comes to editing and that is why I wanted to use the simple hooks plug in



    No worries Nat.

    Stacy, i was actually going to do that but with a smaller amount of code using this:

    and write this into a small function but didn’t think leaving the comment meta for date and time in the source code would be a problem. Still interested to try and make it work.

    Which Genesis file did you grab all the code from?



    Nat, as I noted, Brad’s solution is almost certainly the right choice for you (and probably for most situations).

    Also, Brad, that function really looks like the way to go.

    I took the code from the genesis_comment_callback which is in genesis/lib/structure/comments.php



    Thanks Stacy. Missed your comment last time.



    What if I just wanna remove the TIME from the comment date? How would I go about doing that. I’m using 2.0 btw~



    This CSS code will hide but not remove from the database, all comment meta for date from all posts.



    Removing the time can’t be done with CSS without removing the date as well.

    You would need to use the WordPress comment form args to filter the output of the comment meta data.

    $args: An array of arguments for controlling the output of the comment form.

    There’s no information on filtering it

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.