As I’m getting used to Wordpress 2.1, I’ll post new stuff that will hopefully help you.
By now, you should have noticed that as you write, your posts are autosaved and automatically displayed in the Post Preview section at the bottom. The problem with this is that if you are an Adsense publisher, the iFrame that displays your post’s preview will actually be executing the code and serving your Adsense ads. This means you are generating valuable ad unit impressions that nobody is viewing! This then lowers your eCPM (lots of ads, very few clicks) - which generally lowers your earnings potential. If you’re a prolific writer, these “false” ad unit impressions will really add up.
I found a couple of work-a-rounds to this problem, but here are what I consider to be the 2 best options. These are for Wordpress 2.0 or higher, so I’m not sure if they will work on lower versions.
Option 1 : Remove the Post Preview from the post page.
There is a plugin that will help, but I much prefer the method below.
Open the post.php file located at wp-admin/post.php . Now look for the code that causes the Post Preview iFrame to appear. You’ll find the code near the top :
| <div id=’preview’ class=’wrap’> <h2 id=”preview-post”><?php _e(’Post Preview (updated when post is saved)’); ?> <small class=”quickjump”><a href=”#write-post” mce_href=”#write-post”><?php _e(’edit ↑’); ?></a></small></h2> <iframe src=”<?php echo add_query_arg(’preview’, ‘true’, get_permalink($post->ID)); ?>” width=”100%” height=”600″ ></iframe> </div> |
Delete this block of code, save the file and upload it to your server. This should remove the post preview iframe. If you’re like me and you prefer not to delete code from the original files, you have two options. First, you could save the original file as different file name (eg. posts_original_copy.php).
The other would be to place comment tags (<!- -)around the block of code like this :
| <!- - the comment tag starts here <div id=’preview’ class=’wrap’> <h2 id=”preview-post”><?php _e(’Post Preview (updated when post is saved)’); ?> <small class=”quickjump”><a href=”#write-post” mce_href=”#write-post”><?php _e(’edit ↑’); ?></a></small></h2> <iframe src=”<?php echo add_query_arg(’preview’, ‘true’, get_permalink($post->ID)); ?>” width=”100%” height=”600″ ></iframe> </div> the comment tag ends here - -> |
If you enclose the block of code within comment tags, you don’t have to worry about losing any of the original code. Adding your own comments also help you to remember why you altered the code.
Option 2 : Force Post Preview to stop serving Adsense ONLY to you.
Paste the following lines of code just before your Adsense code snippet :
| < ?php global $posts, $current_user; if($posts[0]->post_author != $current_user->ID) { ?> |
And this immediately after your Adsense code snippet :
| < ?php } ?> |
Now your final code should look like this :
| < ?php global $posts, $current_user; if($posts[0]->post_author != $current_user->ID) { ?> –Your Adsense Code Here– < ?php } ?> |
Okay, this is what the code does. The first part calls the global variables $posts and $current_users which are the post information and information of the current user.
If the current user is an author of the blog, he would most likely have logged in. The ‘if’ statement checks whether there are any posts that have been authored by him. If the current user IS an author - nothing happens ie. no Adsense ads show up. If the current user isn’t an author (a visitor) then the AdSense code will be served. If you WANT to check the Adsense ads, you’ll have to log-out as Author and view your post as a normal visitor.
This seems like a more practical and easily implemented solution to option 1. In the first option, your Post Preview iFrame doesn’t appear at all, so you can’t really check how your post will look until you publish it. It’s okay for folks who are comfortable working in code, but if you’re not, then I’d recommend the option 2.
Popularity: 34% [?]
Wordpress 2.2.1 released
Wordpress 2.1 403 Forbidden Error During Post
Full RSS Feed Plugins For Wordpress 2.1
Upgrading Wordpress 1.5 to Wordpress 2.1
My one of a kind Wordpress Theme
Limiting Kontera ContentLinks On Your Pages
Thanks for this post! I’ve been having problems with the post preview and the second option solved it nicely!
I just have to remember to log out when viewing my blog otherwise the ads will keep showing!
[…] the iFrame that displays your post’s preview will actually be executing the code and serving your Adsense ads. This means you are generating valuable ad unit impressions that nobody is viewing! This then […]