Title: DFP &#8211; Different Ad Code Depending on Category?
Last modified: August 21, 2016

---

# DFP – Different Ad Code Depending on Category?

 *  [mr.eric](https://wordpress.org/support/users/mreric-1/)
 * (@mreric-1)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/dfp-different-ad-code-depending-on-category/)
 * Hello All, thanks in advance for any help with this.
 * I am converting our Adsense ads to the DFP Ad Server, and I’m not able to set
   this up so far so that we can target specific categories with different ad codes.
   So if a 3rd party advertiser wants to buy ad space to display only in the Fitness
   category, for example, I need a way to do that.
 * I am trying this so far:
 *     ```
       <?php if ( in_category( 'Recipes') ): ?>
       AD CODE 1
   
       <?php elseif ( in_category( 'Fitness') ): ?>
       AD CODE 2
   
       <?php elseif ( in_category( 'Menu Planning') ): ?>
       ADE CODE 3
   
       <?php endif; ?>
       ```
   
 * …and of course I’ve added the header part of the ad code just before the closing
   </head> tag in header.php.
 * Maybe this is a case of where I’m placing the ad code, but it’s not showing up
   anywhere, and I have given it quite some time because I know it can take some
   minutes for the ads to start appearing.
 * Any suggestions or instruction from anyone who has successfully done category-
   specific targeting with DFP?
 * Thanks again,
    Eric

The topic ‘DFP – Different Ad Code Depending on Category?’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [DFP](https://wordpress.org/support/topic-tag/dfp/)
 * [doubleclick](https://wordpress.org/support/topic-tag/doubleclick/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 0 replies
 * 1 participant
 * Last reply from: [mr.eric](https://wordpress.org/support/users/mreric-1/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/dfp-different-ad-code-depending-on-category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
