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.
Example 1
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;
}
Example 2
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;
}