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

powered by WassUp

Recent Posts: Fully Net Worth . com

Buck Henry Net Worth: How Rich was Buck Henry Actually?

Buck Henry Net Worth: How Rich was Buck Henry Actually?

Buck Henry was an American actor, screenwriter, and director best known for his directing the movie Heaven Can Wait. Buck Henry net worth before his death is estimated to be $6 million. Henry was born on December 9, 1930, in New York City to Ruth Taylor and Paul Steinberg Zuckerman. His mother was an actress […]

Andre Rison Net Worth: How Rich is the Retired NFL Player?

Andre Rison Net Worth: How Rich is the Retired NFL Player?

Andre Rison also known as Bad Moon is a retired American Football player who played for teams like Indianapolis Colts, Atlanta Falcons, Cleveland Browns, Green Bay Packers and Oakland Raiders. As of 2019, Andre Rison net worth is estimated to be around $200,000. Rison was born on March 18, 1967, in Flint, Michigan. He attended […]

ABG Neal Net Worth: How Rich is the Rapper Actually?

ABG Neal Net Worth: How Rich is the Rapper Actually?

ABG Neal is an upcoming rapper who is known for songs such as “Blurry”. He is also the CEO of a production & distribution company called Bix 8 Baby which he started only recently. As of 2019, ABG Neal net worth is estimated to be $150,000. Neal was born on November 19, 1995, in Brooklyn, […]

%d bloggers like this: