Community Forums › Forums › Archived Forums › General Discussion › How to Unlink Comment Date and Remove Time?
- This topic has 18 replies, 3 voices, and was last updated 10 years, 4 months ago by Regev.
-
AuthorPosts
-
September 22, 2014 at 11:00 am #125330September 22, 2014 at 12:15 pm #125341MarcyParticipant
I don't see any dates or times on that page.
The best method to use to customize your post info is to use the Genesis Simple Edits plugin.
https://wordpress.org/plugins/genesis-simple-edits/
If you need to know all the shortcodes you can use,
http://my.studiopress.com/docs/shortcode-reference/
Marcy | Amethyst Website Design | Twitter
September 22, 2014 at 12:21 pm #125343RegevParticipantI'm talking about the linked date in the comments (not the post itself)
September 22, 2014 at 2:53 pm #125360MarcyParticipantThe easy way to remove BOTH the date and time is to add this below the comments section in style.css
.comment-meta {
display: none;
}If you really want to remove ONLY the time, you have to do two things:
- first filter the genesis_comment_list_args
- and then rewrite the genesis_comment_callback function with the get_comment_time part removed.
But I found this earlier forum post. Just copy all the code in the order written into your functions.php
Use the code in the post from stacyvlasits - http://www.studiopress.community/topic/using-simple-hooks-to-remove-comment-date/#post-25849
Marcy | Amethyst Website Design | Twitter
September 22, 2014 at 3:06 pm #125363RegevParticipantThanks Marcy! but he doesn't talk about removing that link though, there must be an easier way to do both at once
or perhaps.. if i just go the easy CSS route to remove both the date and time - is there an easy way to just add the date manually somehow, perhaps through a short function snippet?
September 22, 2014 at 3:45 pm #125372MarcyParticipantUnfortunately, I don't think there is. I can't find a filter for either Genesis or WordPress.
You just have to add all the code to rewrite the line that adds the link around the date and time.But looking at his code and the genesis code, his code is for XHTML, not HTML5, so it needs to be modified.
Here is the code that does what you want. Just add it to the bottom of your functions.php.
add_filter( 'genesis_comment_list_args', 'custom_comment_list_args' ); //* Filter the genesis_comment_list_args to add a custom callback function function custom_comment_list_args( $args ) { $args['callback'] = 'custom_comment_callback_no_date'; return $args; } function custom_comment_callback_no_date( $comment, array $args, $depth ) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> <article <?php echo genesis_attr( 'comment' ); ?>> <?php do_action( 'genesis_before_comment' ); ?> <header <?php echo genesis_attr( 'comment-header' ); ?>> <p <?php echo genesis_attr( 'comment-author' ); ?>> <?php echo get_avatar( $comment, $args['avatar_size'] ); $author = get_comment_author(); $url = get_comment_author_url(); if ( ! empty( $url ) && 'http://' !== $url ) { $author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author ); } /** * Filter the "comment author says" text. * * Allows developer to filter the "comment author says" text so it can say something different, or nothing at all. * * @since unknown * * @param string $text Comment author says text. */ $comment_author_says_text = apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) ); printf( '<span itemprop="name">%s</span> <span class="says">%s</span>', $author, $comment_author_says_text ); ?> </p> <p <?php echo genesis_attr( 'comment-meta' ); ?>> <?php 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() ) . '</a> ' . __( 'at', 'genesis' ) . ' ' . esc_html( get_comment_time() ); echo '</time>'; edit_comment_link( __( '(Edit)', 'genesis' ), ' ' ); ?> </p> </header> <div <?php echo genesis_attr( 'comment-content' ); ?>> <?php if ( ! $comment->comment_approved ) : ?> <?php /** * Filter the "comment awaiting moderation" text. * * Allows developer to filter the "comment awaiting moderation" text so it can say something different, or nothing at all. * * @since unknown * * @param string $text Comment awaiting moderation text. */ $comment_awaiting_moderation_text = apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) ); ?> <p class="alert"><?php echo $comment_awaiting_moderation_text; ?></p> <?php endif; ?> <?php comment_text(); ?> </div> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'before' => sprintf( '<div %s>', genesis_attr( 'comment-reply' ) ), 'after' => '</div>', ) ) ); ?> <?php do_action( 'genesis_after_comment' ); ?> </article> <?php //* No ending </li> tag because of comment threading }
Marcy | Amethyst Website Design | Twitter
September 22, 2014 at 4:33 pm #125381RegevParticipant0_0
is that html5 or xhtml?
thanks a lot darcy, really appreciate the time and effort
September 25, 2014 at 9:36 am #125674RegevParticipantI managed to remove the comment date and the link through this code that I found and edited a little bit:
// 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', __( '', 'genesis' ) ) ); ?> </div><!-- end .comment-author --> <div class="comment-meta commentmetadata"> <?php printf( __( '%1$s', 'genesis' ), get_comment_date()); ?> <?php edit_comment_link( __( 'Edit', 'genesis' ), g_ent( '• ' ), '' ); ?> </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 */ }
but the comment content begins a line or two earlier and it looks very strange. Here's a screenshot. Any idea what in the code might be causing that?
Also, what are those <div class="comment-right"> and <div class="comment-left"> ? i don't see any right and left columns in the comments so am i missing something?
September 25, 2014 at 12:50 pm #125700MarcyParticipantThe code you list is the same code section I posted above.
Did you try to paste the code I posted at the bottom of your functions.php?
What happened? Did it work?
Marcy | Amethyst Website Design | Twitter
September 25, 2014 at 5:24 pm #125735RegevParticipantThanks Darcy, I tried to use the code you provided but it doesn't work. It simply 'unlinks' the comment time - but still links the comment date and still shows the time.
The code I put above does work - it only shows an unlinked comment date and nothing else. But the comment 'content' doesn't begin nicely from a clean spot but from one line below the date, which looks very strange. Look at this screenshot to see what I mean.
Any Idea what I should change?
Thanks again, you're beyond awesome
September 25, 2014 at 5:47 pm #125736MarcyParticipantYes, it does this:
"but still links the comment date and still shows the time"because I didn't read your second line in your original post. I thought you only wanted to unlink the date. :-/
I've pasted the code again.
Cheers, Marcyadd_filter( 'genesis_comment_list_args', 'custom_comment_list_args' ); //* Filter the genesis_comment_list_args to add a custom callback function function custom_comment_list_args( $args ) { $args['callback'] = 'custom_comment_callback_no_date'; return $args; } function custom_comment_callback_no_date( $comment, array $args, $depth ) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> <article <?php echo genesis_attr( 'comment' ); ?>> <?php do_action( 'genesis_before_comment' ); ?> <header <?php echo genesis_attr( 'comment-header' ); ?>> <p <?php echo genesis_attr( 'comment-author' ); ?>> <?php echo get_avatar( $comment, $args['avatar_size'] ); $author = get_comment_author(); $url = get_comment_author_url(); if ( ! empty( $url ) && 'http://' !== $url ) { $author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author ); } /** * Filter the "comment author says" text. * * Allows developer to filter the "comment author says" text so it can say something different, or nothing at all. * * @since unknown * * @param string $text Comment author says text. */ $comment_author_says_text = apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) ); printf( '<span itemprop="name">%s</span> <span class="says">%s</span>', $author, $comment_author_says_text ); ?> </p> <p <?php echo genesis_attr( 'comment-meta' ); ?>> <?php printf( '<time %s>', genesis_attr( 'comment-time' ) ); echo esc_html( get_comment_date() ); echo '</time>'; edit_comment_link( __( '(Edit)', 'genesis' ), ' ' ); ?> </p> </header> <div <?php echo genesis_attr( 'comment-content' ); ?>> <?php if ( ! $comment->comment_approved ) : ?> <?php /** * Filter the "comment awaiting moderation" text. * * Allows developer to filter the "comment awaiting moderation" text so it can say something different, or nothing at all. * * @since unknown * * @param string $text Comment awaiting moderation text. */ $comment_awaiting_moderation_text = apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) ); ?> <p class="alert"><?php echo $comment_awaiting_moderation_text; ?></p> <?php endif; ?> <?php comment_text(); ?> </div> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'before' => sprintf( '<div %s>', genesis_attr( 'comment-reply' ) ), 'after' => '</div>', ) ) ); ?> <?php do_action( 'genesis_after_comment' ); ?> </article> <?php //* No ending </li> tag because of comment threading }
Marcy | Amethyst Website Design | Twitter
September 26, 2014 at 3:01 am #125790RegevParticipantYOU ROCK MARCY !!!!
Working perfectly, you have no idea how thankful I am.
Is there a way to incorporate the following code into this snippet to make the it more organised?
//* Modify the size of the Gravatar in the entry comments add_filter( 'genesis_comment_list_args', 'mobile_first_comments_gravatar' ); function mobile_first_comments_gravatar( $args ) { $args['avatar_size'] = 96; return $args; }
I also noticed that changing the avatar size doesn't change its size but its 'resolution' - when I set it on 48 the gravatar becomes blurred, whys that
September 26, 2014 at 9:52 am #125827MarcyParticipantYou can comment out your custom avatar function, and add this line.
$args['avatar_size'] = 96;
to my first function above this line.
$args['callback'] = 'custom_comment_callback_no_date';
The resolution of the gravatars is a whole different thing right now. 🙂
Are you looking at the blurry 48px gravatar on a computer screen with retina display?
The 96px allows for 2X resolution when displayed at 48px.The 48px display should be in your style.css.
Marcy | Amethyst Website Design | Twitter
September 26, 2014 at 1:18 pm #125851RegevParticipantWhat do you mean 'comment out' my custom avatar? you mean replace
$args['callback'] = 'custom_comment_callback_no_date';
with$args['avatar_size'] = 96;
?Yes I'm looking at the blurry 48px form my MacBook Pro Retina. So the functions control the resolution and the stylesheet control the actual size?
September 26, 2014 at 1:36 pm #125854MarcyParticipantI said 'custom avatar function' - the one you listed above.
Do NOT replace
$args['callback'] = 'custom_comment_callback_no_date'; with $args['avatar_size'] = 96;
or your comment date links will be the same as before.If you want to combine the avatar function with the comments function, then the whole 1st function in my code above should look like this:
add_filter( 'genesis_comment_list_args', 'custom_comment_list_args' ); //* Filter the genesis_comment_list_args to add a custom callback function function custom_comment_list_args( $args ) { $args['avatar_size'] = 96; $args['callback'] = 'custom_comment_callback_no_date'; return $args; }
The answer to your retina question is: Yes
Marcy | Amethyst Website Design | Twitter
September 26, 2014 at 2:58 pm #125860RegevParticipantAwesome! it works!
any line to add so that I can incorporate that too and reduce the mess?
//* Remove comment form allowed tags add_filter( 'comment_form_defaults', 'sixteen_nine_remove_comment_form_allowed_tags' ); function sixteen_nine_remove_comment_form_allowed_tags( $defaults ) { $defaults['comment_notes_after'] = ''; return $defaults; }
Thanks again Darcy
September 27, 2014 at 9:24 am #125947pressdeamonParticipantI got this code to work for translating a few things, but the word "reply" at the bottom of the comment won't change. I see there's something about that on the code, but couldn't figure out what to edit to change the "reply" text. This text won't change with .po translations or editing directly the comment-template.php, so I thought of using this code as it worked for the other areas of the comment form.
September 27, 2014 at 10:36 am #125954MarcyParticipant@Regev No, that's not part of the comment_callback; that's the form; just leave as is
@pressdeamon You would need to add some arguments to the comment_reply_link function; the default is "Reply"
Here is the WordPress Codex page explaining it.
http://codex.wordpress.org/Function_Reference/comment_reply_linkYou need to add a "reply_text" argument to comment_reply_link function.
If you don't know how to do this, you may want to start a new thread; there may be a better method than this.
Marcy | Amethyst Website Design | Twitter
September 29, 2014 at 6:06 am #126131RegevParticipantQueen Marcy any way to make the comment author name 150% 'font-weight'ier (a little bold), and reducing the comment date text to about 70% smaller?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.