rentfetch_filter_property_title
You may encounter a client who, for technical reasons, does not have the ability to rename property names to be what they’d like to display as the property title on their marketing site. The rentfetch_property_title filter takes care of that situation and lets you customize that to be whatever you’d like it to be.
Basic usage
add_filter( 'rentfetch_filter_property_title', 'my_custom_property_title', 10, 1 );
function my_custom_property_title( $title ) {
// Modify the $title as needed
return $title;
}
Examples
Remove formatting from property titles
In this example, all properties have titles in this format – Apartment Name (999). We’d like to automatically remove the numbers and parenthesis.
add_filter( 'rentfetch_property_title', 'my_property_title' );
function my_property_title( $title ) {
$title = preg_replace('/\([0-9]+\)/', '()', $title);
$title = str_replace(array( '(', ')' ), '', $title);
return $title;
}
Replace property titles
In this example, we have a custom field called custom_display_name and we’d like to use that in place of the title for all properties.
add_filter( 'rentfetch_property_title', 'my_property_title' );
function my_property_title( $title ) {
$default_title = get_the_title();
$landmark_title = get_post_meta( get_the_ID(), 'custom_display_name', true );
if ( $custom_title )
return $custom_title;
if ( $default_title )
return $default_title;
return null;
}
Where It’s Used
This filter affects property titles in:
- Single property pages
- Property archive grid view
- Property archive list view
- Property search results
- Related properties sections