Top 10 WordPress Hacks

WordPress is already a powerful enough engine, but the hacks that we will show you today will allow you to unleash every bit of power that is still somehow trapped in this great blogging engine. Here is a list of the 10 top hacks for WordPress that we have chosen for you.

No 10. Displaying Adsense Ads to search engine visitors only

102 Top 10 WordPress Hacks

Using this code, you can, as the name suggests, have the flexibility of displaying Adsense Ads to those who come from the search engine itself. You might not be aware of the fact that regular visitors don’t click on Ads, but the ones coming from the search engines do, so this code will help you optimize your blog by adding this little trick to your arsenal.

function scratch99_fromasearchengine(){

$ref = $_SERVER[‘HTTP_REFERER’];

$SE = array(‘/search?’, ‘images.google.’, ‘web.info.com’, ‘search.’, ‘del.icio.us/search’, ‘soso.com’, ‘/search/’, ‘.yahoo.’);

foreach ($SE as $source) {

if (strpos($ref,$source)!==false) return true;

}

return false;

}

Use the above code in functions.php and then paste the following code in the template where you want the Ads to appear:

if (function_exists(‘scratch99_fromasearchengine’)) {

if (scratch99_fromasearchengine()) {

INSERT YOUR CODE HERE

}

}

No 9. Displaying Gravatars in comments

93 550x193 Top 10 WordPress Hacks

This code will allow you to display Gravatars in the comments for your blog. Open up comments.php and first find the following line of code:

<?php comment_text() ?>

Then replace this code with the following:

<div class=”gravs”>
<?php if (get_bloginfo(‘version’)>=2.5)
echo get_avatar( $comment->comment_author_email, $size = ’50’, $comment->comment_author_link);?>
<?php comment_text() ?>
</div>
<br clear=”all” />

Now, use the following in style.css for CSS:

.gravs {margin-top:20px;}
.avatar {float:left; margin-right:5px; margin-bottom:5px; padding:3px; border:1px solid #999999;}

Popular on the Web

Leave a Reply