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 rel="nofollow" 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

Bill Aydin Net Worth- How Rich is Jennifer Aydin’s Husband?

Bill Aydin Net Worth- How Rich is Jennifer Aydin’s Husband?

Dr. Nebil Bill Aydin is a Double Board Certified Plastic and Reconstructive Surgeon. His specialization lies in aesthetic cosmetic surgery of the face and body. Aydin is originally from Istanbul, Turkey but had migrated to Los Angeles in the U.S. when he was 16. As of 2019, Bill Aydin net worth is estimated to be […]

Dakotaz Net Worth: How Rich is the Twitch Streamer Actually?

Dakotaz Net Worth: How Rich is the Twitch Streamer Actually?

Brett Hoffman, who is better known by his online alias as Dakotaz, sometimes referred to as DK, is a Twitch Streamer and a Youtuber. He is an active player of the game Fortnite and today has over 4 million followers on his Twitch channel. As of 2019, Dakotaz Net Worth is estimated to be $2.5 […]

Ben Zobrist Net Worth: 4 Interesting Facts You Should Know

Ben Zobrist Net Worth: 4 Interesting Facts You Should Know

Ben Zobrist is an American professional baseball second baseman and outfielder who currently plays for the Chicago Cubs of Major League Baseball. Early Life Ben was born on May 26, 1981, in Eureka, Illinois to Cynthia and Tom Zobrist. He started playing baseball when he was eight years old. He graduated from Eureka High School […]

%d bloggers like this: