1. Docs
  2. Developer Guide
  3. Miscellaneous and Snippets
  4. Adding Availability or Marketing Flag To Search Results Thumbnail

Adding Availability or Marketing Flag To Search Results Thumbnail

One of the most common questions we get asked is how to add a graphic or text over the thumbnails on the search results page. This might be used to flag up if the property has a certain availability such as Sold STC, or it might be show a marketing flag such as ‘Price Reduced’ or similar.

The reason that we don’t include this in the templates by default at present is because there are so many different variations of how people want this to display.

To add the flag simply add the following to your theme’s functions.php file:

add_action( 'propertyhive_before_search_results_loop_item_title', 'add_flag', 5 );
function add_flag()
{
    global $property;

    $flag = $property->availability;
                 
    if ( $property->marketing_flag != '' )
    {
        $flag = $property->marketing_flag;
    }

    if ( $flag != '' )
    {
        echo '<div class="flag">' . $flag . '</div>';
    }
}

You’ll need to add some CSS depending on how and where you want the flag to appear. Some sample CSS can be found below, assuming you’re using the default templates and class names:

.properties li.property .thumbnail a { display:block; height:100%; position:relative; }
.properties li.property .thumbnail .flag { position:absolute; top:0; left:0; background:#000; color:#FFF; }

It also might require a bit of tweaking if, for example, you don’t want the flag to appear on properties for sale or to let.

Was this article helpful to you? Yes No