Things they don't teach you in school
I’ve written a very cool Wordpress Plugin and repackaged a pre-existing pack of 30 themes that will make your life a lot easier if you’re trying to use Adsense on your blog. The themes are very clean two column with middle content designs. What makes my package special is the layout manager which allows you to select where your advertising and navigation columns appear on your site. You can choose from six different layouts. The themes are have locations where you can place your ads, whether they are Yahoo or Google or Adbrite, etc. The name of the product is EZ Adsense Wordpress but it can be used with other advertising programs besides Adsense. Each theme includes a color scheme and header graphic which you can customize to your heart’s desire.
The motivation behind the project was to make it extremely simple to monetize your blog without hacking any source files. The one screen setup will allow you configure many elements of your advertising elements on your blog. If you’re a Clickbank.com fan, you can enter your Clickbank affiliate code, some keywords and my plugin will show selected products from Clickbank.com using your affiliate code. So when your users click the ad and (hopefully) purchase, you’ll get full credit. I’ve got several blogs up and running using the system:
http://www.ezadsensewordpress.com
You can visit the info page here:
http://www.ezadsensewordpress.com/ezwp/info.html
The plugin and theme pack are $39 one time fee. I’ve also setup a support forum at http://forums.ezadsensewordpress.com/
By default, when you install a wordpress blog and start blogging, your home page displays all of your recent posts. However, with Adsense, you can only display 3 ads per page. Most Wordpress users put an ad at the end of each article. If you do this on your home page, you can only display three articles so the theory is why display all of them on one page?
This hack is part one of two.
The initial fix is easy. Open your Wordpress Theme Editor (wp-admin -> Presentation -> Theme Editor ) and click on the right side menu item titled “Main Theme Template”
The line you need to fix looks like this:
<?php if (have_posts()) { while (have_posts()) { the_post(); ?>
If we change this line to the following:
<?php $x=0; if (have_posts()) { while ($x++<3 && have_posts()) { the_post(); ?>
Then your main page will only display the latest three entries. Your users can still browse your other articles by clicking categories and archive links.
Part two of this hack will provide you with a nifty little Post Pager that will list links to all of your other recent posts at the end of the main page.
I did some hacking with Word Press today to replace its built-in search with Google Adsense Search. It was fairly easy, and I’ll explain how in this post.
First you’ll need to setup your Adsense account and get your search code. During the setup process you will be asked an important set of questions which controls how the search results are displayed. By default, Google opens a separate window to display your search results. This resulted in an ugly format, and lacked my WordPress theme. Choose the options as shown in the window below:
This should result in Google providing you to pieces of code, the Search Box code, and Search Results code. Use the Search box code in your leftcolumn.php theme file to replace the search box that WordPress defines.
I made some changes to Google’s generated code to make it fit my left column, and to make sure it posted to the index.php. Google uses a lot of hidden form fields to define the search results. We will use one of these hidden fields to tell our theme index.php file to display search results instead of the blog posts.
Here’s the portion of my hacked theme index.php that displays Google’s Adsense-enabled search:
At the top of my index.php, before the blog post code:
<div class=”centreblock”>
<?php if(isset($_GET['client'])) { ?><!– Google Search Result Snippet Begins –>
<div id=”googleSearchUnitIframe”>&tl;/div><script type=”text/javascript”>
var googleSearchIframeName = ‘googleSearchUnitIframe’;
var googleSearchFrameWidth = 700;
var googleSearchFrameborder = 0 ;
var googleSearchDomain = ‘www.google.com’;
</script>
<script type=”text/javascript”
src=”http://www.google.com/afsonline/show_afs_search.js”>
</script>
<!– Google Search Result Snippet Ends –>
<?php } else {?>
Now, further down the file, you will see this:
<?php
include_once(’leftcolumn.php’);
include_once(’rightcolumn.php’);
?>
</div> <!– centreblock –>
We need to add the following line:
<?php } // end google search if ?>
<?php
include_once(’leftcolumn.php’);
include_once(’rightcolumn.php’);
?>
</div> <!– centreblock –>
Of course, depending on your WordPress theme, your actual code might be different. I’m trying to think of other cool Googlish hacks I can do to WordPress, got any ideas?
web·pit n. a place of discovery; a repository of information; where coders come for enlightenment; a programmers diary.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Mar | ||||||
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |