rentfetch_filter_floorplan_title
The rentfetch_filter_floorplan_title filter allows you to modify the title of floorplan posts before they are displayed. This filter is applied in the rentfetch_get_floorplan_title() function and affects how floorplan titles appear throughout the Rent Fetch plugin.
Usage
add_filter( 'rentfetch_filter_floorplan_title', 'my_custom_floorplan_title', 10, 1 );
function my_custom_floorplan_title( $title ) {
// Modify the $title as needed
return $title;
}
Parameters
- $title (string)
The original floorplan title fromget_the_title().
Return
(string) The modified floorplan title.
Examples
Add Property Name to Floorplan Title
For small multi-property websites, you may want to show a combined view of all of the floorplans, but you’d still like your users to be able to see at a glance which floorplans belong to which property. Here’s a snippet that can help:
// How to add the property title to each floorplan
function rf_add_property_title_to_floorplan_title( $title ) {
$property_id = get_post_meta( get_the_ID(), 'property_id', true );
// do a query for properties with this property_id
$args = array(
'post_type' => 'properties',
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => 'property_id',
'value' => $property_id,
)
)
);
$propertylist = get_posts( $args );
$property = $propertylist[0];
if ( $property->post_title )
$title = sprintf( '%s - %s', $property->post_title, $title );
return $title;
}
add_filter( 'rentfetch_filter_floorplan_title', 'rf_add_property_title_to_floorplan_title', 10, 1 );
Customize Title Format
function customize_floorplan_title_format( $title ) {
// Remove any existing prefixes and format consistently
$title = 'Floor Plan: ' . $title;
return $title;
}
add_filter( 'rentfetch_filter_floorplan_title', 'customize_floorplan_title_format', 10, 1 );
Where It’s Used
This filter affects floorplan titles in:
- Floorplan archive grid view (floorplan-each-grid-default.php)
- Floorplan archive list view (floorplan-each-list-default.php)
- Single floorplan template (single-floorplans.php)
Notes
- The filter receives the raw title from WordPress’s
get_the_title()function - Changes made here will be reflected wherever
rentfetch_get_floorplan_title()orrentfetch_floorplan_title()are called - The filter runs within the floorplan post context, so you can access floorplan metadata using
get_the_ID()orget_post_meta()