Connect with us

Tips & Tricks

Display custom url if comment authors url is blank

Here is a nifty trick for your comments.php template. If someone comes to your site and leaves a comment but doesn’t leave a url back to there site, the default link that is shown in place of the php code comment_author_url is the current page link.

That might not look good. So, here is a little trick that I just implemented into my site. Besides installing the twittar plugin and pulling Twitter avatars I wanted to use the image itself for the authors url like. But if the author doesn’t have a Twitter avatar or a Gravatar it will display a default Gravatar that I set. If the default Gravatar is shown, usually the author will not leave a url link.

I would like to link the image to Gravatar.com so that they can get an image attached to their email address. So.. here is the code:

<?php if($comment->comment_author_url != "") { ?>
<a href="<?php comment_author_url(); ?>"><?php gravatar(); ?></a>
<?php } else { ?>
<a href="http://gravatar.com" title="Get a Gravatar today!"><?php gravatar(); ?></a>
<?php } ?>

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

Josh Groban Net Worth

Josh Groban Net Worth

Joshua Groban Joshua Winslow Groban is an American songwriter, record producer, actor, and singer. Groban was born on February 27, 1981, in LA, California. Both his parents were artistically inclined and instilled the love of music and theater in their children. Melinda, his mother was an interior designer and an artist while Joshua inherited the […]

Mike Bushell Net Worth: How Rich is Mike Bushell Actually?

Mike Bushell Net Worth: How Rich is Mike Bushell Actually?

Mike Bushell is an English sports presenter who is best known for his appearances on BBC Breakfast. He is an adventurous man who holds an incredible world record for participating in the greatest number of different sports. He achieved this feat while working for BBC One. As of 2019, Mike Bushell net worth is estimated […]

Omi In A Hellcat Net Worth: How Much is the YouTuber Worth?

Omi In A Hellcat Net Worth: How Much is the YouTuber Worth?

Omi In a Hellcat is an American YouTube personality and entrepreneur who depicts his sensational lifestyle through vlogs on his YouTube channel. As of 2019, Omi In A Hellcat net worth is estimated to be $60 million. Unfortunately, Omi’s real name is unavailable to us. He was born on August 6, 1985, in Philadelphia, United […]