Conditional template tags for detecting coupon pages, queries, and taxonomy archives in your own theme code.
Coupon Creator (the free plugin Pro builds on) registers a set of conditional functions modeled on WordPress core tags like is_single(). Use them in a child theme or snippet to run code only on coupon-related views. Each returns a boolean and is filterable.
Functions #
cctor_is_coupon( $post_id = null ); // true on a single coupon (optionally test a specific post ID)
cctor_is_coupon_category(); // true on a coupon category archive
cctor_is_coupon_query(); // true when the current page is running a coupon query
cctor_is_coupon_taxonomy(); // true on a coupon taxonomy archive
cctor_is_coupon( $post_id )— passes throughapply_filters( 'cctor_is_coupon', ... , $post_id ).cctor_is_coupon_category()— filterable viacctor_query_is_coupon_category.cctor_is_coupon_query()— filterable viacctor_query_is_coupon_query.cctor_is_coupon_taxonomy()— filterable viacctor_query_is_coupon_taxonomy.
Example #
add_filter( 'body_class', function ( $classes ) {
if ( cctor_is_coupon() ) {
$classes[] = 'has-single-coupon';
}
if ( cctor_is_coupon_category() ) {
$classes[] = 'coupon-category-archive';
}
return $classes;
} );
Pro adds a companion tag, cctor_get_current_template(), which returns the current page template name (filterable via cctor_get_current_template) — useful when branching logic on the print view versus the shortcode view.
See also Coupon Loop & Filter Bar for query-level filters and Pro CSS Reference.