epl_get_listing_status(): status of the current listing
Description #
Returns the status of the current listing: the saved property_status value, usually current, sold, leased, withdrawn or offmarket. Outside a listing it returns an empty string. Use it in the loop or on a single listing template. The filter of the same name changes the result.
Usage #
$status = epl_get_listing_status(); add_filter( 'epl_get_listing_status', 'my_function' );
Parameters #
The function has no parameters. It reads the current listing from global $property and returns a string.
Filter:
$status (string)
The saved status, or '' outside a listing. The filter has no listing parameter: use global $property if you need the listing.
Examples #
Show a note on sold listings:
if ( 'sold' === epl_get_listing_status() ) {
echo '<p class="my-sold-note">This property has sold. Ask us about similar homes.</p>';
}
Treat withdrawn listings as off market everywhere this function is used, including epl_get_listing_status_label():
function my_epl_listing_status( $status ) {
return 'withdrawn' === $status ? 'offmarket' : $status;
}
add_filter( 'epl_get_listing_status', 'my_epl_listing_status' );
The filter only changes code that calls this function. Templates that read property_status with get_property_meta() aren't changed. For other listing checks see Conditional tags.
Source #
lib/includes/functions.php, in epl_get_listing_status(). Since 3.6.