Car Demon Code Docs

  1. Home
  2. Car Demon Code Docs
  3. Display Filters
  4. cd_ribbon_filter


This filter can be used to adjust the photo ribbon on both the vehicle SRPs (Search Result Pages) and VDPs (Vehicle Display Pages).

apply_filters( ‘cd_ribbon_filter’, $ribbon, $post_id, $size );


$ribbon = the current ribbon HTML code.
$post_id = the post id for the current vehicle.
$size = if given then this will be a numeric value used for both height and width.

add_filter( 'cd_ribbon_filter', 'my_ribbon', 10, 3 );
function my_ribbon( $ribbon, $post_id, $size ) {
     //= get the car array and assign it to $car
     $car = cd_get_car( $post_id );

     //= is this a "New" car
     if ( 'New' === $car['condition'] ) {

          //= Change the $ribbon to our own custom image source
          $ribbon = '<img src="" width="' . $size . '" height="' . $size . '" id="ribbon">';


     return $ribbon;

The above example checks the vehicle condition, if it’s a new vehicle then it changes the ribbon HTML to a custom ribbon.

Was this article helpful to you? Yes No

How can we help?