Advanced: Customizing Ad Display

One of the things we get asked about a lot is how to avoid detection from Ad Blockers. While we've explained other options to respect those visitor's ad display preferences, we understand that there are some instances that you aren't using AdSanity for typical advertising. Maybe you're just using AdSanity to track views and clicks on Image based content, for example. We provide you with a couple of methods to modify the display of individual ads, groups of ads, or all ads.

Styling Ad Units

Each Ad Unit has a number of CSS Classes and a unique HTML ID that you can target in your theme's CSS to change its look. The format of these are:

  1. ad-{size} (example: ad-125x125) - This allows you to style all ads of the same size
  2. column-{column number} (example: column-2) - While relevant only to groups of ads, this allows you to style all ads in a particular column
  3. alignleft | aligncenter | alignright | alignnone - These four styles are generally already handled inside of most themes, but if you want to apply additional styles to better handle alignment, this is the place to do so. Note: only one class will be added to each ad unit.

If all of those classes don't suit your needs or you want to change them, you can attach additional classes to each Ad Unit using a filter as described below.

Display Related Hooks

There are a few display related actions and filters built into our templating system. These allow you to filter CSS classes and add markup around the ad unit so that you can style it.



Theme Templates

Sometimes you need to have more control over the markup for your ads. We've extended WordPress Core's template hierarchy to allow you to fully customize an ad's markup through a theme template.

If you want to change the markup of all ads, simply copy the ad.php file from the theme-templates folder into your theme and customize away.

If you want to modify the markup for all ads of a particular size, you can rename that file to something like ad-125x125.php, where 125x125 is the size that you're trying to modify. Note: you can find the size by looking at the classes that are applied to the ad in the markup.

Finally, if you want to change the markup of one particular ad, you can rename the file to ad-1234.php where 1234 is the ID of the ad you want to modify. Note: you can find the ID by looking at the HTML ID that is applied to the ad in the markup.

Didn't find what you were looking for?

If you're a subscriber to AdSanity and don't find an answer to your specific question please submit a request and our support department will address your issue quickly.