Can I fliter Loop Item Title?
-
Hi everyone,
I’m currently working on a WordPress site using the Property Hive plugin and am looking to customize the loop title displayed for each property in the search results loop. By default, the title is set to the page title, but I’d like to create a custom variation different to and instead of the default title.
I was hoping to either add filter or remove action by using the
propertyhive_search_results_loop_item_title
hook to achieve this, but I’m not sure if this hook even exists or if there’s a better way to go about it.https://docs.wp-property-hive.com/article/586-using-actions
Here is sample code
// Remove the default loop title action
remove_action('propertyhive_loop_item_title', 'propertyhive_template_loop_title');
// Add custom function to output
add_action('propertyhive_loop_item_title', 'my_custom_loop_title');
function my_custom_loop_title()
global $property;
// Create the custom_loop_title variable
$custom_loop_title_parts = array(
$property->_bedroom . ' Bed',
$property->property_type,
'in ' . $property->_address_three,
$property->_address_postcode
);
$custom_loop_title = implode(' ', array_filter($custom_loop_title_parts, fn($part) => !empty($part)));
// Output custom title with concatenated details
echo '<h3><a href="' . get_permalink() . '">' . esc_html($custom_loop_title) . '</a></h3>';
}My questions are:
- Does the
propertyhive_search_results_loop_item_title
hook exist, and if not, is there an alternative hook I should use to achieve this? - Is there a better approach to customizing the loop title in the Property Hive plugin without altering templates?
Any guidance would be greatly appreciated. Thanks in advance!
- Does the
- You must be logged in to reply to this topic.