Address rules: show_street_address, show_suburb, show_address_city, show_address_country
Description #
From Easy Property Listings 3.6, every address function asks the same four rules, so the address is shown or hidden the same way everywhere: the listing heading, archive cards, widgets, maps and shortcodes. Use them in templates and add-ons instead of reading the checkboxes yourself.
All of them are methods of the global $property object. For how the address fields work, see How the Address system works.
The rules #
show_street_address() #
Show the street address? True when the listing's Display Street Address box is checked.
Filter: epl_listing_show_street_address ($show, $property)
show_suburb() #
Show the suburb? Always for residential listings. For commercial, commercial land and business listings: when Display Suburb is checked, or when the street address shows.
Filter: epl_listing_show_suburb ($show, $property)
show_address_city() #
Show the city? True when Settings > Address > Additional Address Field is enabled.
Filter: epl_listing_show_address_city ($show, $property)
show_address_country() #
Show the country? True when Settings > Address > Display Country is enabled.
Filter: epl_listing_show_address_country ($show, $property)
Examples #
Ask the rule in a template or add-on
global $property;
if ( $property->show_street_address() ) {
echo esc_html( $property->get_property_meta( 'property_address_street' ) );
}
Never show the street address on rentals
add_filter( 'epl_listing_show_street_address', function ( $show, $property ) {
if ( 'rental' === $property->post_type ) {
return false;
}
return $show;
}, 10, 2 );
Because every address function asks the same rule, this one filter hides the street address everywhere at once.
Related #
Since 3.6.