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 } ?>
3 Comments

3 Comments

  1. Pingback: Weekend Links - Jan 16, 2009 | OMNINOGGIN

  2. Pingback: Weekend Roundup #32 » JaypeeOnline // Blogging News & Reviews

  3. arcade games

    March 11, 2009 at 3:13 pm

    very nice idea, it could be an advertising slot.

You must be logged in to post a comment Login

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

YNW BSlime Net Worth: How Much is the Rapper Actually Worth?

YNW BSlime Net Worth: How Much is the Rapper Actually Worth?

YNW BSlime is an American rapper from Florida. He is known for working alongside his older brother YNW Melly. He has dropped tracks like Slime Dreams, Just Want You, and Gucci Belt. As of 2019, YNW BSlime net worth is estimated to be $150,000. YNW BSlime’s real name is Brandon King and was born on […]

Guapdad 4000 Net Worth: How Rich is the Rapper Actually?

Guapdad 4000 Net Worth: How Rich is the Rapper Actually?

Akeem Hayes, who is better known by his stage name as Guapdad 4000, is an American rapper who is best known for his debut album that was only recently released called Dior Deposits. In the past, he has released a mixtape too called Scamboy Color. As of 2019, Guapdad 4000 net worth is estimated to […]

Michael J Pollard Net Worth: How Rich was the Actor Actually?

Michael J Pollard Net Worth: How Rich was the Actor Actually?

Michael J Pollard was an American actor and comedian best known for his role as C.W. Moss in the movie ‘Bonnie and Clyde’. Michael J Pollard net worth before his death is estimated to be $1.5 million. Pollard was born on May 30, 1939, in Passaic, New Jersey as the son to Sonia V. and […]

%d bloggers like this: