Car Demon Code Docs

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


This filter is used to modify the vehicle item on a SRP (search result page).

It also modifies the vehicles displayed on an archive page or displayed by the vehicle shortcode [cd_inventory].

apply_filters( ‘cd_srp_filter’, $x, $post_id );

add_filter('cd_srp_filter', 'my_car_item',10,2);
function my_car_item( $content, $post_id ) {
    // $content is the default vehicle listing
    // $post_id is the id for the vehicle being displayed

    // set $car equal to the vehicle detail array
    $car = cd_get_car( $post_id );
    // You can use the elements from the $car array to populate your output.
    $content = 'This is my new content: ' . $car['year'] . ' ' . $car['make'] . ' ' . $car ['model'];
    return $content;

The above example would change your vehicle search results to show each vehicle as:

This is my new content: 2010 Ford Focus

Obviously it would show the correct year, make & model for each vehicle.

NOTE: If you’re going to fully recreate the listings it’s a good idea to wrap each one inside it’s own <div> tag to help separate them from each other.

TIP: You can use print_r( $car ) in your code to see the full output of the $car array.


    print_r( $car );
Was this article helpful to you? Yes No

How can we help?