The Display Conditions are one of the most powerful, but complex features in Advanced Ads. They allow you to define the attributes of pages on which the ad should show up or hide in very fine detail.

If you use Advanced Ads Pro, these conditions not only give you more control over ads but also allow you to use this feature for placements too.

Please note that Display Conditions are not injecting ads (this is what Placements are for). They only limit already injected ads to specific pages.

List of available Display Conditions

The available Display Conditions are dynamic. For each public taxonomy (Categories and Tags by default), new conditions are added.

Accelerated Mobile Pages (AMP)The AMP condition allows you to display ads on Accelerated Mobile Pages. See Display Ads on AMP pages.
Archive: {taxonomy}While {taxonomy} is a placeholder for any taxonomy (Categories and Tags by default), this option can be used to limit ads to specific archive pages. Archive pages are lists of posts or other post types belonging to a specific taxonomy.

Every taxonomy has its own display condition set. The defaults are Categories and Tags.


With more than 50 terms per taxonomy, there is a search field instead of a list with all terms.

AuthorThe Authors Condition allows you to limit ads to posts from specific authors.
Content AgeThe Age condition allows you to display ads based on the age of the content, e.g. “older than 5 days”
FeedThe Feed condition allows you to display ads in the Feed of your site. See Ads in Feeds.
Format, Archive: Format
Post Formats are a feature in some themes allowing you to customize the output of a post.
General Conditions
The General Conditions are a set of most important page types and active by default.

Find remarks on Secondary Queries below.

Pagination
Display ads only on specific pages in a paginated post.

Advanced Ads Pro
Paid Memberships Pro
Display or hide ads based on the defined membership level of content pages.

ManualAdvanced Ads Pro

Parent Page
Display an ad based on the parent page for hierarchical post types (including pages).

Advanced Ads Pro
Post Meta
The post meta condition allows you to target a meta value attached to a post or page.

Advanced Ads Pro

Post Type
Choose the public post type of content where the ad can be displayed. This condition is working on single pages as well as archive pages.
Post Type / Page TemplateDisplay ads based on the post type template (since WordPress 4.7).

Advanced Ads Pro

Specific Pages
Display or hide an ad from specific published posts or pages. Just start typing the title of the page to see suggestions or search for the post/page ID.

Manual

TaxonomyWhile the Archive: {taxonomy} condition can be used for individual terms from a given taxonomy, the Taxonomy condition is meant to limit ads to archive pages for all terms belonging to a taxonomy.
{taxonomy}, Categories, Tags
While {taxonomy} is a placeholder for any taxonomy (Categories and Tags by default), this option can be used to limit ads to posts that belong to these specific terms.
Every taxonomy has its own display condition set. The defaults are Categories and Tags.
URL ParametersDisplay ads based on URL parameters. This is useful if you have specific parameters in your URL or you want to create additional display conditions.
ManualAdvanced Ads Pro
WPML languageDisplay ads based on the page language set by the WPML plugin.

Advanced Ads Pro

Video

In this video (4:08 min) I am explaining how to use the Display Conditions. The manual below might cover these topics in more detail, but I think it is a good starting point.

Start Video
(click to start)

Usage

You can set Display Conditions in the Display Conditions meta box on the ad edit screen. If you want to display the ad everywhere, you don’t need to set any display conditions. Some conditions allow you to select whether you want to show or hide ads only on pages with the selected feature.

You can

  • add more conditions by adding them through the New condition option. (see the list of display conditions below).
  • remove conditions by clicking on the (x) button behind the line. The fewer conditions you use, the better for your site’s performance.

Blue elements are activated, while grey elements are disabled.

Choices within a condition set are combined via OR. For example, when you select multiple categories for a post with an ad, the post only needs to belong to one of these categories for the ad to show up.

Advanced Ads selected categories
The ad with these Display Conditions would only show up on posts that are in one of the selected categories: Featured, Best articles, or News.

Combining conditions with AND and OR

This is what you need to know when combining conditions:

  • conditions are checked in the order they are set
  • the OR operator means that the next condition is checked, even if the previous one was false
  • you can understand conditions combined by OR as blocks where only one of the conditions needs to be true to show an ad
  • the AND operator means that the whole check is stopped and returns false when any of the conditions connected with AND is false
Advanced Ads AND OR switch

By default, different conditions are combined via OR. This means that only one of the set conditions needs to match to show the ad.

The following example combines two Categories conditions. It displays the ad in posts with the “Best Articles” category but prevents it from showing up in posts that are also in the “News” category.

Advanced Ads categories conditions

You can also change the connector from OR to AND by just clicking on it. An OR connector in front of a condition simply means that the previous condition can be false, but the whole conditions return true if the OR combined check is true.

Ads in specific pages or in specific category
In this example, the conditions are connected using OR, because it is impossible for a single page to be the “Display Conditions Manual” page and the “Best Articles” category page at the same time. So, using AND here would result in the ad never to show up.

Display Conditions Examples

Here are some showcases for Display Conditions. Understanding the examples will help you get the most out of your conditions. The examples given here for categories work exactly the same for tags and custom taxonomies.

Post Categories and the Category Archive
A common setup is to display an ad on posts with a specific category and on the archive page of that category. The problem occurs when using the wrong connector AND instead of OR.
Wrong Setup: Using AND
Display Condition Configuration
The setup above uses AND to connect both conditions.
Why is using AND wrong here?
If you translate this setup into a sentence, it might sound like this:

Show the ad on posts with the Best Articles category and on archives of the Best Articles category.
However, Advanced Ads does interpret this setup as conditions that should match the same page. So the real interpretation is:

Show the ad on pages that are posts with the Best Articles category and archives pages of the Best Articles category at the same time.
Since it is technically impossible to have a page that is a single post and an archive at the same time, this ad would never show up anywhere.
Why does it work anyway?
If you have the setup above, it will still work like expected. Why? Since this specific wrong setup is so common, especially from a version where this wasn‘t handled so strictly, Advanced Ads automatically rewrites the AND into an OR.
Correct Setup: Using OR
The correct setup is therefore using an OR as a connector
Combining the same category conditions
The meaning of AND and OR might also become more clear when combining the same taxonomy based conditions.
Show in different categories
If you want to display an ad in posts with different categories, you would basically use the following setting:



This reads as:

Show the ad on posts with the Best Articles category OR the Evergreens category.

and is basically the same as:



With this setting the post can be in either or both of the categories so that the ad will show up.
Show in posts with both categories
If you want to display the ad only in posts belonging to both categories at the same time and not only one of them, you should use the following setup.


Notice the AND used to connect the conditions.
Using IS and IS NOT
Some conditions have a IS/IS NOT setting, which basically means that the ad should show up on pages with the conditions or should not show up on them.

The crucial difference you should understand here is:

  • IS: the ad only shows up on pages with exactly that condition

  • IS NOT: the ad is only removed from pages without that condition, but would still show on all other page types
  • Using IS



    The ad with the above display condition would show up only on a single post page with a post belonging to the Best Articles category. It would not show on other page types, e.g. home page, archive pages, static pages.
    Using IS NOT


    The ad with the above display condition would NOT show up on a single post page with a post belonging to the Best Articles category. It would still show on posts from other categories and other page types like home page, archive pages, static pages.

    In order to limit the page types in this case, add a General Conditions setting.
    Combinations with IS and IS NOT
    Using the correct connector is also crutial when working with IS and IS NOT.



    The setup above reads like:

    Show the ad on posts with the Best Articles category that ARE NOT in the Uncategorized category.
    So, posts within the Best Articles category, but without belonging to the Uncategorized category would show the ad, while all other posts within the Best Articles category would display it.
    Why not to use OR here?
    If you used OR here to connect both conditions, the ad would show up on all page types (including home page, archives, static pages, etc.), except for posts in the Uncategorized category. You could get the same result without having the IS condition before that.
    Combining Categories and Tags
    Combining multiple taxonomy based conditions is also possible and AND vs. OR make even more sense here.
    Show for Category OR Tag
    If you want to display an ad in posts belonging to either a specific category or a tag, use a setup like the following:

    display condition setup of advanced ads

    This reads like:

    Show the ad on posts belonging to the Best Articles category OR the Computer tag.
    Show for Category AND Tag
    If you want to display an ad in posts belonging to a specific category AND tag, use a setup like the following:

    Display Conditions Configuration of Advanced Ads

    This reads like:

    Show the ad on posts belonging to the Best Articles category AND the Computer tag.
    Just belonging to one of them would not show the ad.
    Combining multiple conditions – OR vs. AND
    Understanding the difference between the OR and AND operator between conditions is critical to building complex condition sets.
    This is what you need to know when combining different conditions:
  • conditions are checked in the order they are set

  • the OR operator means that the next condition is checked, even if the previous one was false

  • you can understand conditions combined by OR as blocks where only one of the conditions needs to be true to show an ad

  • the AND operator means that the whole check is stopped and returns false when any of the conditions connected with AND is false

  • The following example uses AND and OR conditions.

    Display Conditions example OR vs AND 1

    The example reads like this:

    Show the ad when the current page (is an AMP page) AND (is a post in the “Featured” category OR the archive page of the “Featured” category).

    Imagine that all conditions that are connected using OR are a block in which only one condition needs to be true. When using AND between these blocks then each of these blocks needs to return true at least once and no block can be ignored.

    If we use /amp/ in the URL as an indicator that the page is using AMP then we can see the result of the checks in the following table.

     /single-post//single-post/amp//category/featured//category/featured/amp/
    is AMPfalsetruefalsetrue
    is post in “Featured” category page
    OR
    is “Featured” category archive
    truetruetruetrue
    resultad NOT displayedad displayedad NOT displayedad displayed

    Debugging Display Conditions

    There are various reasons why Display Conditions could not work, here are some:

    • a custom query was not used properly
    • the conditions are wrongly connected (e.g., AND used instead of OR)
    • the content is requested via ajax
    • the content is requested in an iframe

    Neither of the problems above is caused by Advanced Ads, but there is a way Advanced Ads can help you to solve them. Switch the ad to debug mode for more information.

    See Using the ad debug mode.

    What else you need to know

    Practically, you don’t need to set display conditions in case you use the ad in a place where it should always appear. The more specific the place, e.g. using the the_ad() function within a specific template file like single.php the less careful you probably need to define the display conditions.

    Secondary Queries

    Secondary Queries in WordPress could be a list of posts that don’t belong to the post type but are added in addition. E.g. on a single post the main post would be the primary query, but a list of related posts in the sidebar or post teasers below the main article could be a secondary query.

    With ad injections, it can happen that teasers from secondary queried posts also contain ads. To prevent this from happening you can disable ads on Secondary Queries on a per-ad basis or globally in the plugin settings.