Wordpress is what it is. It’s a script made for bloggers. It’s not the best CMS in the world. You couldn’t run NYTimes.com with Wordpress. It’s simply not that powerful. WP is built small and medium sized websites. And this is of course also one of the biggest advantages with the system. The simplicity. Even a 90-year old could run a website with wp. In fact, the reason why I love this system and recommend it to others is beacuse of the great simplicity. Its not easy. Not complicated. And I like that.
But with simplicity comes less possibilites. Look at a site like NYTimes.com. Look at how the articles are displayed on the front page. Could you do that with WP? Yeah. But, it will require a lot of work from you as the webmaster. Further, look at the ads on NYtimes. Look at how they are related to the content. Look at subpages on football. There you’ll find ads of products related to football. Could you do that with WP? Yeah, but again; it require some work from you as the webmaster.
Basically, to make a long intro short, I’ll show you a easy way to display targeted ads to your readers based on content, using php. This method works, but it require some editing of templates, and some basic understanding of php, html and possibly CSS. I don’t recommend getting on this if you’re a newbie to the net or WP.
Ok, what you want is of course a ad that is relative to your content. Example; on the single pages which are in the category “Google Adsense” you want to display banner ads from the Adsense referal program. Or, on the single pages which are in the category “Mobile Phones” you want to display ads from Nokia or Samsung.
To do this, you could simply call the function if ( in_category(’X’ ): display this ad.. in your single page template called single.php (which WP use to display single pages). The code looks like this:
<?php if ( in_category(’1′) ): ?>
Ad code here…
<?php endif; ?>
This function tells WP that if the article or post is in the category with the ID “1″, it should do what you have specified where I have written “Ad code here..”. Later there is a code snippet saying “end if“, closing this little code snippet. You don’t have to have a ad there, of course. You could have anything you want. But, this method is great for displaying ads on a category basis.
You’ll find the ID of each category in the WP-admin under “categories”.
In my late project, still in development, Agurkposten, I’ve used this method to both display ads on a category basis, and showing a special header-image for each category. Still not done with with the site, but if you visit these two links, you’ll see this code in action:
http://agurkposten.no/?p=55
http://agurkposten.no/?p=52
I also use this little code snippet to show previous entries in the category of the post you’re reading. So, if you read a post you’ll get a little list in the sidebar with links to all the other posts in that category. Great for navigation of course.
Remember that you could use codes like this to do a almost anything. It’s only your creativity that stops you.
PS! Still in very poor shape, thats why the activity on this blog has been very slow lately. It’s my disease which is giving me a hard time. Went to the hospital today, again, and got some new medicine. Hopefully I’ll be fit for fight soon.


















Categories:
Links:
Archives:
Meta:
Search: