You are missing a “NOT” logical operator (!) in your if statement.
You want to say “if comment author IS NOT empty”. As of now, the function is reading that the author is not empty and defaulting to your else statement that tells it to output the author’s full name. Use the second block of code but make the following change.
Change the following:
if ( empty($comment->comment_author) ) {
to:
if ( !empty($comment->comment_author) ) {
Otherwise it looks ok to me.
Related Posts:
- Check If comment author is registered
- Comment Author Name In Reply Form
- Display all comments or recent comments per user on author page
- how to make author to write comment on only his own posts?
- How to check if commenter is the_author?
- Let user edit his own comment
- edit comments capability for authors
- Why are authors allowed to approve comments on their posts? How to revoke privilege?
- Hide notifications regarding new comments
- List user comments in author page
- Author can only see own post comment and can moderate
- WordPress comments on users profile
- Comment displaying full name even after setting another display name?
- Same email for all comments
- Notify post author for a new comment on his post?
- How many members have made comments approved for an article?
- Commentlist: bypostauthor problem with children list
- Only Allow post author and “Premium” Role user to comment
- get_comment_author_link not working properly
- Get Comment Author ID on the fly while posting
- How can I hide comment of the authors from their published posts?
- WordPress Custom Local Avatar not showing in comments
- Attaching author tag to the comment
- How to prevent users/authors from seing IP/email of new commentators?
- Author name length character limit?
- Comments counter only for Authors Posts
- Comments pagination on author page
- Change author, disable comments, enable trackbacks for all items in library
- Prevent author from editing comments from others in their post
- URLs to user page is broken
- How to ‘If Author’ Comments Check
- Auto approve all comments (editor)
- How do we remove the H3 tag for the reply-title I.D
- How to display comment form error messages in the same page
- 3 moderators to approve comment
- show number of open comments on custom dashboard
- How to hide “Trackback” on paginated comments
- Is it possible to show custom comment metadata in the admin panel?
- Does WordPress Allow Blank/Empty Comment Submissions In WordPress?
- How can comments be submitted when I don’t have a comment box on a page?
- how to have 2 comments_template() in one post
- Display the number of user comments
- Display comment meta data after quick update
- get_comments() where parent is not 0
- How to hide “Comments are disabled”
- Get number of comments per page
- Custom disqus_identifier not properly changing default value
- Edit Comment_Field while using T5 Comment Textarea On Top-Plugin
- Registered but Anonymous comments
- How to import only certain comments from post[s]
- Make wordpress comments work with include templatepath
- Callback function argument which is required for wp_list_comments ()
- The comment login form is visible to me but not to the user
- How to insert a comma to the child comment construction in function.php?
- Custom WP Comments Query with Nested Comments Possible? (Hierarchy/Depth)
- Log file reports SQL Error processing child comments
- how to properly use comments-template.php
- Reply By Email to comment notifications
- Get Post ID within wp_set_comment_status hook
- How to implement comments on specific fields in wordpress?
- wp_list_comments renders incorrectly nested
- Alternative to the filter comment_reply_link
- Number/ Position of a Comment
- Comments are invisible, what’s the problem with wp_list_comments?
- WP confusing “links to my articles” with “comments”?
- How to check if a comment has replies?
- Can I have Comments open to specific users only?
- Comments does not work?
- How do I disable the discussion notification emails to us when a comment is “approved” and when an adiministrator replies?
- Review count per product
- Moving post’s content to post’s comments section
- comment_notes_before not working
- why can’t I retrieve the comment ID?
- Returning error upon comment being flagged as spam
- is it possible to have the full code instead in the comments.php page
- JetPack comment threads are displaying above comment box? [closed]
- How do i remove approved spam comments by date?
- Insert ads between comments
- get_query_var(‘paged’) for WP_Comment_Query always return 1 when using paginate_comments_links()
- How to only show current user’s comments and comments on current user’s posts in wp admin
- How to make author comment name to “Editorial Staff” no matter which ever author is replying to comments from his/her account?
- How to show username in reply to comment?
- Display date and time into post edit comments section
- Disallowed Tag Present in AMP WordPress ()
- Comments/Discussion Not enabled on newly created posts/pages
- Fire Social Annex Code on Comment Approval
- Change Comment Text [duplicate]
- Comments closed but enabled on edit screen
- Let user delete comment on front end only
- jQuery to Create Button to Show/Hide WordPress Comments and to Hide Comments by Default
- Comment form – different title if no comment yet
- WordPress Comments jQuery Doesn’t submit
- Loop not displaying comments_popup_link
- Display of comment_date within get_comments?
- How to batch convert comments to posts?
- prevent duplicate comments using wp_insert_comment
- I need help about wordpress of members section
- How to disable comments on new blog post, but allow on new products?
- Get approved comments or comments that the author is me
- Show/Hide comments