Sizlopedia

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

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

Ram

Thats a good trick. You can also use templates for categories, then you can style or display information specific to that category

Thanks a lot its really gonna help me in my search for latest stumbles for my site.

Interesting guide. Thanks for the detailed guide on how to embed Google Adsense Ads to categories. Is there other parts in Wordpress where you can embed Ads?

@Rommel

The best position to embed Google ads is above the content and below the title of article. There you get the highest click through rates.

Leave a Comment

Name: (Required)

E-mail: (Required)

Website: (Optional)

Comment: