Support » Plugin: Ad Code Manager » Add conditional to exclude a category

  • I’m using ACM to generate DFP tags on my entire website. I want to replace these ad units on posts of a specific category to display different ad units.

    The conditional is defined for the category, but the ROS tags must be excluded on posts in this category.

    I want to add a custom conditional with the following code:

     * ACM: Custom conditional
    add_filter( 'acm_whitelisted_conditionals', 'my_acm_whitelisted_conditionals' );
    function my_acm_whitelisted_conditionals( $conditionals ) {
        $conditionals[] = 'not_has_category';
        return $conditionals;
    add_filter( 'acm_conditional_args', 'my_acm_conditional_args', 10, 2 );
    function my_acm_conditional_args( $cond_args, $cond_func ) {
    global $wp_query;
    if ( in_array( $cond_func, array( 'has_category', 'has_tag' ) ) ) {
       if ( $wp_query->is_single == true ) {
            $cond_args[] = $wp_query->queried_object->ID;
    return $cond_args;

    What modifications to the above code will exlude the DFP tags “if not has category”?

  • The topic ‘Add conditional to exclude a category’ is closed to new replies.