Thursday, 11 November 2010

New Banner Advertising - Technical

(see other posts for details of advertisers)

The new banner adverts presented a bit of a technical challenge:

The ads must ONLY appear on the FIRST page of the homepage..

Wordpress has a function called is_home(), which returns true on the homepage, but it also returns true on subsequent pages /page/2.. etc
The solution is to use if (is_home && !is_paged()), which means "on the homepage, but not paged"...

Now, that's fine in a template, but what if the ads are appearing in a text widget?
You can't use php code in a text widget..
The solution is a plugin called exec-php.. which works like a text widget, but allows php code.
The downside to this is that on pages the adverts don't appear, there is a blank box.

Example


Finally, have a close look at the advert for motors.co.uk.. the text "cars for sale" is the ONLY clickable part of the advert. This is for SEO purposes. It ensures that the keywords "cars for sale" are associated with the address "www.motors.co.uk". Neat. :)


We are considering filling the blank with an advert for advertising on the site.. :)

No comments:

Post a Comment