Community Forums › Forums › Archived Forums › Design Tips and Tricks › Using Simple Hooks to remove comment date
- This topic has 10 replies, 4 voices, and was last updated 11 years, 8 months ago by
Brad Dalton.
-
AuthorPosts
-
March 13, 2013 at 4:54 am #25815March 13, 2013 at 5:20 am #25817
Brad Dalton
ParticipantThis CSS code will hide the date and time:
.comment-meta { display: none; }
Paste it at the end of your child themes style.css file.
March 13, 2013 at 8:53 am #25849stacyvlasits
MemberBrad'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>
<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><?php do_action( 'genesis_after_comment' );
/** No ending </li> tag because of comment threading */
}
March 13, 2013 at 8:57 am #25852Nat
MemberWorked a treat. Thank you very much Brad
March 13, 2013 at 9:00 am #25854Nat
MemberSorry 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
March 13, 2013 at 11:11 am #25883Brad Dalton
ParticipantNo worries Nat.
Stacy, i was actually going to do that but with a smaller amount of code using this:
http://codex.wordpress.org/Function_Reference/delete_comment_metaand 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?
March 13, 2013 at 12:06 pm #25894stacyvlasits
MemberNat, 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.phpApril 20, 2013 at 3:47 am #36526Brad Dalton
ParticipantAugust 16, 2013 at 3:22 pm #56913Jenny
MemberWhat if I just wanna remove the TIME from the comment date? How would I go about doing that. I'm using 2.0 btw~
August 16, 2013 at 3:51 pm #56918Brad Dalton
ParticipantThis CSS code will hide but not remove from the database, all comment meta for date from all posts.
https://gist.github.com/braddalton/6253744
August 16, 2013 at 5:30 pm #56939Brad Dalton
ParticipantRemoving 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 http://codex.wordpress.org/Function_Reference/delete_comment_meta
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.