How to change the WP_Query arguments the [coupon] shortcode uses to select which coupons display.
The [coupon] shortcode builds a WP_Query from its attributes and then passes the argument array through a filter before running it. Hook cctor_shortcode_query_args to change ordering, add a meta or tax query, or otherwise alter the result set.
add_filter( 'cctor_shortcode_query_args', function ( $args ) {
// Order coupons by title instead of date.
$args['orderby'] = 'title';
$args['order'] = 'ASC';
return $args;
} );
The array you receive contains the standard keys the shortcode sets, including post_type (cctor_coupon), post_status (publish), posts_per_page, orderby, p (when couponid is used), and cctor_coupon_category.
Scope a filter to one shortcode #
Add filterid="..." to a shortcode and a matching, per-ID filter fires only for that instance:
[coupon filterid="featured"]
add_filter( 'cctor_shortcode_query_args_featured', function ( $args ) {
$args['posts_per_page'] = 3;
$args['orderby'] = 'rand';
return $args;
} );
This lets one shortcode on the page use custom query rules while other [coupon] shortcodes stay on the defaults.
Note on the default count #
A bare [coupon] with no totalcoupons attribute is capped (default 50) via the cctor_default_totalcoupons filter, not posts_per_page directly. Passing totalcoupons="-1" explicitly still returns every published coupon.