Conditional ad display when using shortcodes

Home Forums AdRotate for WordPress Adverts and Banners Conditional ad display when using shortcodes

  • #162922

    Gil
    Badges:

    Hi, Arnan. Are there any conditional display options in AdRotate Pro, in terms of preventing ads/ad groups added via shortcodes from displaying when a post is set to a specific category or is tagged in a certain way? I see that ads can be inserted based on post categories and/or on specific pages, but it would be helpful to have a way to say, this ad group appears in all posts unless the post category is, say, “Obituaries”? Thanks!

    #162934

    Arnan de Gans
    Badges:

    Shortcodes are placed where you want adverts to show so they don’t really need any settings like that.

    You use Wordpress conditional tags when placing PHP snippets though.

    #162936

    Gil
    Badges:

    Thanks, Arnan. Let me try asking the question a different way. If my client is creating a new post, which is based on the theme’s single post template, and has an AdRotate ad group inserted in an “ad” spot in the template, is there any way, using the WordPress classic or block editor, that they can prevent that ad from being displayed on a specific post while being shown on all others?

    #163939

    Arnan de Gans
    Badges:

    Hi Gil,
    SOrry for the late reply – If that template spot is a theme feature then probably not most themes do not support such logic.
    If it’s a premade file where you added PHP snippets from AdRotate you can use the WordPress Conditional Tags I mentioned earlier.
    And if it’s a copy/paste template you wrote as a text, simply remove the shortcode from it for the few posts that don’t get the ad.

    For the tags, is_single would probably do the trick.

    if(!is_single(array(POST_ID, ANOTHER_POST_ID))) echo adrotate_group(1);

    For example, the ! in the code means ‘is not’. Removing it will show the group only on those IDs.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

You may be interested in