How To: Fixing Popularity Contest Plugin for WordPress 2.5
June 7, 2008 by Tony | Tag(s): Popularity Contest, WordPress Code, WordPress How-To
The problem(s): With some upgrades of the WordPress 2.5 branch, the Popularity Contest WordPress plugin is not working properly. Also, people trying to activate the Popularity Contest plugin on a brand new WordPress install are getting a fatal error or a “doesn’t exist” message when attempting to activate the plugin.
The solution(s): I actually ran into this problem on a fresh install of WordPress. After several attempts, I was unable to figure out the problem myself. Thankfully, a quick Google search showed a post over at WPGuy which gave details on fixing both problems!
Here is what you need to know if you have this problem:
Fix problems with the upgrade to WordPress 2.5
Open your Popularity Contest plugin (edit it) and search for this code:
require('../../wp-blog-header.php');
And replace it with this:
require(’../wp-blog-header.php’);
Fix problems with a new install of WordPress 2.5
In addition to doing the above, you need to search for the following code:
if (isset($_GET['activate']) && $_GET['activate'] == ‘true’) {
And replace it with this:
if (isset($_GET['action']) && $_GET['action'] == ‘activate’) {
I went through both of these steps on my fresh WordPress install and it fixed the problem perfectly!
How To: Adding an Email This Button to Your Blog
June 7, 2008 by Tony | Tag(s): Email Button, Email This, WordPress, WordPress Code, WordPress Hacks
In the past we’ve talked about how to add a print button to your WordPress theme. Today I wanted to give you the javascript code you need to create an Email This button on your WordPress blog.
Before getting to the code, I wanted to first say that this code is designed to allow readers to click on the button and have it open up their default email software and create a subject and link that point to the post the reader is currently visiting. This code is not designed to allow readers to contact the blog author.
If you are wanting your readers to be able to contact you, I recommend you use one of the many great contact form WordPress plugins available. You should never embed your email address into some HTML code because it will be picked up by spam bots. Contact forms prevent spammers from finding your email address. The other thing you can do is offer “EmailAddress AT EmailCompany DOT com” (which your email address information filled in) to avoid spammers.
Okay, so back to the Email button code. Here is the javascript you will need:
<script type="text/javascript">
<!– Begin
function isPPC() {
if (navigator.appVersion.indexOf(”PPC”) != -1) return true;
else return false;
}
if(isPPC()) {
document.write(’<a class=”contact” HREF=\”mailto:\?subject\=Take a look at this page I found, ‘ + document.title + ‘?body=You can see this page at: ‘ + window.location + ‘\” onMouseOver=”window.status=\’Send your friends e-mail about this page\’; return true” TITLE=”Send your friends e-mail about this page”>Email to a Friend<\/a>’);
}
else { document.write(’<a class=”contact” HREF=\”mailto:\?body\=Take a look at this page I found titled ‘ + document.title + ‘. You can see this page at: ‘ + window.location + ‘\” onMouseOver=”window.status=\’Send your friends e-mail about this page\’; return true” TITLE=”Send your friends e-mail about this page” rel=”nofollow”>Email This!<\/a>’);
}
// End –>
</script>
This will create an email where the reader can enter in someone’s email address and send them a link to your post/page.
How To: Adding a Print This Button to Your Theme
June 7, 2008 by Tony | Tag(s): Print Button, Print This, WordPress, WordPress Code, WordPress Hacks
If you ever visit our actual website, you’ve probably noticed the “Print This” button that we display below each post. Depending on the type of website or blog you are running, having a button like this may be a good fit for your blog. I’ve found it to be good to have this button available to readers for any type of website that offers tutorials, recipes, guides, or pretty much anything that might require a visitor to print something you’ve written.
If you think you’d like to offer your readers the option to print something on your blog, here is the code I use on my blogs (uses Javascript):
<a href="javascript:window.print()" rel="nofollow">Print This!</a></span>
It prints the page you are on, so it is probably best to use it mostly on post and pages. If you place it on the blog’s homepage, it will print the entire homepage, not just that post.
How To: Display Adsense On Your First Post Within The Loop
June 7, 2008 by Tony | Tag(s): Google Adsense, WordPress How-To, WordPress Loop
In this guide you’ll learn how to display Adsense on just your first post within the Loop. Sure, there may be plugins that will do this for you. This guide, however, will use code examples to accomplish the same thing by editing your WordPress theme.
The first step is to open up your index.php file in your theme editor. Find the following line:
<?php if(have_posts()) : ?>
Just above that, insert the following like this:
<?php $i = 1; ?>
<?php if(have_posts()) : ?>
Now, scroll down a bit until you find this line:
<?php endwhile; ?>
Insert the following above it, like so:
<?php $i++; ?>
<?php endwhile; ?>
The final step is to insert your Adsense code. Locate where exactly you’d like it within the Loop, and place it between a conditional tag like this:
<?php if ($i == 1) { ?> [YOUR ADSENSE CODE HERE] <?php } ?>
And that’s all you have to do. You can be creative with this code as well. You could add a certain css style class to the top post in your Loop. It doesn’t even have to be the first either, as you can just change the number in $i == 1 to whatever you want. This same method can be used in other archive templates such as archive.php.
How To: Adding the Post Authors Gravatar To Their Individual Posts
June 7, 2008 by Tony | Tag(s): Gravatar, WordPress Comments, WordPress Hacks, WordPress How-To
One thing I am really excited about is that Gravatars are really starting to gain popularity now that Automattic has purchased and is supporting them. And now that support is built right into WordPress, it opens up a lot of options for WordPress users.
The most common place you’ll find a Gravatar is usually with an individual comment to help comments stand out. Another place you will sometimes see them is in the sidebar, like we have it setup here at Hack WordPress. One thing, however, that people are slowly coming around to is using Gravatars with blog posts to identify the author of the post. This is something that is a great idea for a multi-author blog and something I’ve considered doing on this website.
So, how would you go about setting up Gravatars to display with each individual post? Over at ThemeShaper, Ian Stewart recently shared an easy way to do this. You just need the following code:
<?php echo get_avatar( get_the_author_email(), '64' ); ?>
When used, WordPress will match up the e-mail address associated with the post author to determine what Gravatar to use. The 64 is the size (pixels) of the Gravatar.
Great find Ian!

![Subscribe to [Blog Tutorials]](http://blogtut.com/wp-content/themes/BlogTutorialPro/images/rss.gif)
![[del.icio.us]](http://blogtut.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://blogtut.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://blogtut.com/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://blogtut.com/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://blogtut.com/wp-content/plugins/bookmarkify/myspace.png)
![[Newsvine]](http://blogtut.com/wp-content/plugins/bookmarkify/newsvine.png)
![[Reddit]](http://blogtut.com/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://blogtut.com/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://blogtut.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://blogtut.com/wp-content/plugins/bookmarkify/technorati.png)
![[Windows Live]](http://blogtut.com/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://blogtut.com/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://blogtut.com/wp-content/plugins/bookmarkify/email.png)





