Sizlopedia

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanOversetter til Norsk/NorwegianПереведите к русскому/RussianΜεταφράστε στα ελληνικά/GreekVertaal aan het Nederlands/Dutchترجمة الى العربية/Arabic中文翻译/Chinese Traditional中文翻译/Chinese Simplified한국어에게 번역하십시오/Korean日本語に翻訳しなさい /JapaneseTraduza ao Português/PortugueseTraduca ad Italiano/ItalianTraduisez au Français/FrenchTraduzca al Español/Spanish

How to Display Category Specific Content in Wordpress

One thing I love about Wordpress is the great flexibility it offers in terms of designing custom themes and for this all the credit goes to Wordpress Template Tags.

Recently I ran into a problem where I wanted to monetize the posts in my Gadgets category with TTZmedia ads while keeping the normal Google Adsense ads on all other posts. This is when I found the in_category template function which lets you display category specific content in Wordpress.

The function is simple and very easy to use. Just use it in the Loop on any template file and it should work file.

<?php if ( in_category('category_id') ): ?>
// Some category specific PHP/HTML here
<?php endif; ?>

More detailed info and examples can be found on the link below:

http://codex.wordpress.org/Template_Tags/in_category

This can be helpful to monetize posts from certain categories with specific ads and can also be used to display information about a particular category.

A live implementation of this template function can be seen here on Sizlopedia. If you visit any post that belongs to the Gadgets category you will see targeted product ads while in other cases you will see the normal Google Adsense ads.

Comments on this Post

Leave a Reply