If comment_author_link then put the link around avatar image

In the functions.php file for my theme the .commentslist shows a gravatar and if the user fills in a url in the comment form, you get a

comment_author_link()

Which prints a link with the name.

Read More

I want to put a link around the .avatar image IF there is a link. There is zip/zilch in the resources (https://developer.wordpress.org/?s=comment_author&post_type[]=wp-parser-function&post_type[]=wp-parser-hook&post_type[]=wp-parser-class&post_type[]=wp-parser-method).

It would be like this but this doesn’t work:

<?php if ( has_comment_author_link() ) : ?>
  <a href="<?php echo comment_author_url();?>" target="_blank">
<?php endif; ?>

   <?php echo get_avatar( $comment, $size='75' ); ?>

<?php if ( has_comment_author_link() ) : ?>
  </a>
<?php endif; ?>

But there is no such “has_comment_author_link” and I don’t know how to create this.

Thanks!

Solved at WordPress stackexchange: https://wordpress.stackexchange.com/questions/172152/if-there-is-a-comment-author-link-put-url-around-the-avatar-image/172156#172156

Related posts

Leave a Reply