Remove comment author
-
child theme 3.4? Is that a child theme of 2011?
Also, do you wish to just prevent the commenter name from appearing publicly, or you never wish them to input it in the first place?
yes.. twenty eleven 3.4 child
I want the names to not show publically. Using css, they are still there…but not visible to the eye. (not good enough)
Thank you!!
You could use the following code to remove the author’s name from the comment thread and feed. Put this into your child theme’s functions.php file:
if ( ! function_exists( 'hide_comment_author' ) ) : function hide_comment_author( $author ){ return ''; } add_filter( 'get_comment_author', 'hide_comment_author' ); add_filter( 'comment_author_rss', 'hide_comment_author' ); endif;However, you may want to modify your theme’s comment template to account for this so that it doesn’t seem awkward. You will need to override Twenty Eleven’s twentyeleven_comment() function in your child theme. You can do that by creating a new function in your child theme with the same name, pasting the contents of the original twentyeleven_comment() in it, and changing the part that prints the comment info to this:
printf( __( '%1$s', 'twentyeleven' ), sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>', esc_url( get_comment_link( $comment->comment_ID ) ), get_comment_time( 'c' ), sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )));This should fix your theme so that it only tries to display the date/time and it doesn’t look weird.
Aha!The first piece of code worked great. When I added the second piece to functions it made the page full browser in ie (shooooock!) and made no difference in appearance. Now it says
on June 19, 2012 at 5:18 pm
I can live with that! Thank you VERY much
Awesome! I’m glad it worked for you 🙂
Haha I’m not even sure why that chunk of code would do that even that in demon of a browser. I know you said you are fine with that, but I kind of like to get it 100% right. If you want to, you could post your child theme’s functions.php and I could take a look at it ( maybe upload it to Pastebin or something? ) 🙂
If not, I understand – you don’t want to break the part that you just fixed 😛
Hey! I have a bad habit of fixing it until its broke… so here goes! LOL
<?php
if ( ! function_exists( ‘hide_comment_author’ ) ) :function hide_comment_author( $author ){
return ”;
}
add_filter( ‘get_comment_author’, ‘hide_comment_author’ );
add_filter( ‘comment_author_rss’, ‘hide_comment_author’ );endif;
?>
Awesome! Let’s try and get the second part working, too 😀
Perhaps some screenshots would help?
Open your WordPress Dashboard. Go To Appearance->Editor. In the drop down at the top right choose the Twenty Eleven theme (not the child theme). Click on functions.php on the right.
1) Use the find function in your browser to find twentyeleven_comment
2) Copy from
if ( ! function_exists( ‘twentyeleven_comment’ ) ) :
all the way down to and including
endif; // ends check for twentyeleven_comment()
and then switch back to editing your child theme using the drop down and paste that chunk into your child theme’s functions.php3) Replace the part that starts with
/* translators: 1: comment author, 2: date and time */
and ends with
);
in the child theme with the second chunk of code from my first post and it should work! 🙂Let me know how it goes!
The topic ‘Remove comment author’ is closed to new replies.
(@kpelham)
13 years, 11 months ago
I need to remove comment author (for privacy)from comments. Would like to have just the date the comment was submitted.
Does anybody know how to do this? I am using a child theme 3.4
THANKS!!!