Tag Archives: Google

Placing Adsense After Your First WordPress Post

Google Adsense is a great way to make some money off of your blog, and by placing your code in a couple of key places in your template files, you can have it automatically displayed on all of your blog posts. One thing to keep in mind though is that you can only show 3 ads per page, any more than that and in most browsers an empty space will be left, which is to some extent ok, but in other browsers it can appear as a broken iframe or image. While an empty space isn’t ideal, it can be acceptable, a broken section on your site really isn’t.

It’s for this reason that most people will set up their template to only display Adsense code on the first post shown on each page where multiple posts are displayed. For example on your index page, category pages, tag pages and archive pages.

So to ensure that your Adsense code only displays once you need a way to make sure that when WordPress loops through each post, there is some way for it to figure out whether or not it’s the first post. Joe over at joehayes.org has written a great post about doing this.

Somewhere before the start of the WordPress loop, you need a base way to count. Joe has done this by placing the following code:

<?php $count = 1; ?>

Before the WordPress loop which starts off with:

<?php if (have_posts())

Then inside the content section of the loop which starts off with:

<?php the_content

You need to decide whereabouts you are going to put your Adsense code. Paste it in somewhere, this could be before or after the post content, or after the meta information, or anywhere else that be suit your particular template.

Now, just before the start of your Adsense code you need a way to check the number of posts. We’ll use some PHP to check the $count number that we set earlier.

<?php if ($count == 1) : ?>

This checks to make sure it is still 1. If it is, then your Adsense code will be displayed. If not then it won’t be.

Directly after your Adsense code we then need a way to make sure that the other posts don’t also appear as number 1.

<?php endif; $count++; ?>

This section of PHP tells WordPress to add 1 to the counter. So the next time WordPress runs through the loop, it will be a 2 instead, and it will go 1 higher for each post, so only the first post will appear as 1, thus only the first post will show the Adsense code.

It’s pretty simple but it does the trick very well!

If you wanted to display 2 or 3 ads, one on each of the first 2 or 3 pages, you could simply change the PHP around a little bit.

<?php if ($count <= 3) : ?>

The above snippet for example tells WordPress that if the count number is 3 or lower, than it should display the Adsense code with only 2 minor changes to the original code.

Adwords Management

I picked up a new domain name yesterday, http://adwordsmanagement.net.au which I’m thinking I’ll use to create a landing page relating to Google Adwords management as part of the TerraMedia website. I’m not sure when I’ll get round to it though as I’ve got a number of other things on my to do list that are of a much higher priority.

It is quite a good domain name to use for an Adwords management landing page, or even more so for an entire website relating to Adwords management simply because it has exactly those terms in the domain itself – Adwords management. It would be better if it were a global domain, such as a .com or .net, or even if it was the .com.au country coded domain simply because those ones are all easier to remember. Regardless of that though, I think it has potential.

If I haven’t gotten around to doing anything with it when you are reading this, and you are interested in purchasing it, I will consider selling it if the offer is reasonable, so you are welcome to make an offer. Otherwise, hopefully I’ll be setting it up within the next couple of months.

Using the GMap Module with Drupal’s Private File System

If you use the GMap module with your Drupal installation, something you may not realise initially is that a file is created in your Drupal file system called gmap_markers.js.

By default this file goes in sites/default/files/js/gmap_markers.js and is not the same file as the gmap_marker.js file in the Drupal module directory.

When the Drupal private file system is enabled, you cannot directly access a file in the sites/default/files directory, this means that when the the gmap_markers.js file is looked up, Drupal doesn’t allow access to it. Fortunately, GMaps provides a way around this.

Change the location of gmap_markers.js

The first thing you need to do to resolve this issue is to change where the gmap_markers.js file is located. The next thing you need to do is to tell GMap where to find it.

  1. Pick a location outside of the Drupal file system. For example, files/js/gmap_markers.js instead of sites/default/files/js/gmap_markers.js
  2. In your Drupal administration section, go to your GMaps settings and below the “Google Maps API Key” text box, there will be an option to specify the path to gmap_markers.js from the Drupal root directory.
  3. Enter the path.
  4. Save the changes.
  5. Click the “Regenerate” button in the “Regenerate Marker Cache” section.

Your cache should now be rebuilt in the new location using these settings. This should resolve any private file system issues relating to the GMap module in Drupal 6. Drupal 5 may vary a bit and I have not tested this, but I suspect it should still resolve the problem, for the most part, but you may need to use a different directory than what I suggested.

Good luck, if you have any issues or other tips, such as for Drupal 5, I’d love to hear about them in the comments.

Triplify – Search Google, Yahoo and Bing all at once!

The Triplify search box
The Triplify search box

Triplify is a mashup that is highly useful to me as a web site designer, especially when looking at search engine optimisation.

What does it do?

Triplify is a search engine front end that takes your search query and then passes it on to Google, Yahoo and Bing. Those 3 search engines return the search results to Triplify, and it collates and displays them to the user.

By default it sorts the results based on their position in the results of each search engine which is great for quickly seeing where a web site is ranked in each search engine without having to go hunt through them all separately. If you aren’t in the first 16 results though then you are out of luck as Triplify does not currently appear to have paged results available and so only 16 results for each search engine are given. So what you get is something like this:

The first 6 results in a Triplify search for "brisbane web designer"
The first 6 results in a Triplify search for "brisbane web designer"

What do the colours mean?

Google is shown in blue, Yahoo in Red and Bing in that yellow/green colour. I’m not sure that these are the best colours as they don’t really symbolise those search engines. I was thinking while I was using it that the colours aren’t the best choices, in my opinion, Yahoo should be yellow and Bing should be blue and Google red. I’m not entirely sure why though, after all, the Yahoo logo is Red and Google uses blues as well as reds. Blue seems to better suit Bing, after all, blue is very much a Microsoft and Live colour, and Bing is related to both of them. The others I’m really not 100% sure about though. I associate yellow with Yahoo, and I’ve been trying to figure out why for a while now. I think it’s because of the smileys that used to be on their home page in that strong yellow colour that were part of the Yahoo Instant Messenger branding. I used to use YIM quite regularly, so that may be it. Upon thinking about it further, the colour choices are good, they are just not the colours that I associate with each of those search engines.

What else can it do?

If you only want to show the results from two of the search engines, or even only one, just uncheck the boxes below the search box of the ones you don’t want and voila, they are gone! Need them back? Just check the box again and they will reappear.

If you want to sort the results by search engine, or any of the other column headings (though search engine seems to be the only other particularly useful one to me), just click the column heading, for example, click “Title” and the search results will be shuffled into alphabetical order. Click “Engine” and the results will be grouped by search engine.

There is also a handy “Add Triplify to your browser” link at the top of the page which, if your browser supports this feature, will add Triplify as a search option to your browsers search box.

Quirks and nuisances

Unfortunately at the moment, there doesn’t seem to be any way to sort in descending order rather than ascending, this isn’t a big thing, but it would be nice!

The main issue I have is that the sorting is affected by whichever sort you used previously. This can be a handy feature, but it can result in unexpected behaviour. For example, if you are viewing with a position sort, then you sort by search engine. The results will be shown in order of their search engine ranking. Now sort by title, then sort by search engine again. They are now sorted by search engine, but in alphabetical order instead.

Perhaps some explanation of how this works would make it clearer to understand to the new user, it took me playing with it for about half an hour before I realised that it sorted by both the current and previous sort option. My initial assumption was that it should sort Title, Description and URL alphabetically, then search engine should show pages in their ranked order, not in Title, Description or URL order. I do admit, it is useful, but unexpected.

In hindsight, the motto “Search, compare and sort!” does actual indicate that you should be able to do some sort of advanced sorting such as what is available, and if you go to the about page it does explain how the search sorting works, but the about page is hidden in tiny text down the bottom of the page and isn’t exactly the first thing you think of when trying to figure out how to use it. Maybe a more prominent link at the top of the page, such as “Help” on the right hand side underneath the existing tools navigation box that is there.

Final thoughts

I think Triplify is something that is going to play a very important part in my future search engine optimisation efforts. I don’t see any particular appeal in it from a general search point of view because the search results are not as easy to understand as they are in any of the search engine interfaces, but it will save a lot of time determining if a web site is ranked in the top 16 results or not and checking on it’s progress.

It is only in beta, so no doubt the things that are unclear may be cleared up once a 1.0 version is released.

Have you found an interesting use for Triplify? Share it in the comments!

Experimenting with Landing Pages

At TerraMedia, I am currently working on an interesting project. That is, I am working on pushing the website up in search results for a number of different regions.

One of the ones I am working on at the moment is users searching forĀ  web site design and related services in the Byron Bay region. If you do a quick search in Google for “web design Byron Bay” or “Byron Bay web design” or similar, TerraMedia cannot be found on the first page of results. The home page of TerraMedia is visible on the second page in the case of both those queries, but we would like it high up on the first.

There are a couple of places to start here, the first is to update the home page to more specifically target Byron Bay, or, to create a landing page which is optimised for Byron Bay searches. We don’t really want to adjust the home page too extensively as it is currently placed quite well for a number of other regions, so we decided to begin with landing pages, starting with Byron Bay.

To start off with, I have setup a new page on the TerraMedia web site that has all of the keywords we are looking for in both the page title and the page address. The page that I have set up is located at http://terramedia.com.au/web-site-design-services-byron-bay and uses some new copy that is based on copy used in other sections of the website combined with some newly written information to help target potential Byron Bay clients.

A sub-domain or domain that is specifically relevant to these terms may be easier to rank higher, but at the same time, they would lose the benefit of being on the terramedia.com.au domain and could confuse the user in the case of a completely different domain name. Wouldn’t you be confused if you went from say “websitedesignservicesinbyronbay.com” to “terramedia.com.au”? That domain is an exaggerated example and is much too long, but I’m sure you can see how it could get confusing.

Now that the page is created I will be developing links to it and marketing it through our Facebook page and Twitter account.I want to get twitter followers for our page to see how it goes. The aim is then to push this page up in search results specifically regarding web site design in the Byron Bay region.