Add the region title and description on frontend

Hi, I use the feature “Generate regions from locations” and all the regions created on the WordPress website. But I want also to add the region title and description to the front end. for example: when someone chooses the city “New York” in the search form so the result page will show the title of this region which is “New york” and also the description of this region.

Hi,
It should work this way already, but only if you view the region page the same way as you view the category page (e.g., click View on any region in Listings>Regions). If you just search listings by location, it’s a common search page with no title.

Yes, you are right I didn’t notice that. thank you!

Now after I find the way I need to add a prefix to the title with the same word “apartments” for all regions. for example apartments In New York, apartments In France, and so on.

How can I do it?

It’s possible, but in the current version this would require overriding the /page/page-title.php template part via a child theme or using a WordPress filter hook for customizing the taxonomy title (regions are implemented as “hp_listing_region” taxonomy).

Thank you. can you give me the code that I should paste in the page-title.php ?
And if you can give me some PHP lines to insert in function.php it could be better.

Thank you.

I found an easier way, if you’re familiar with PHP customizations please try filtering the template context via the hivepress/v1/templates/listings_view_page hook, checking if it’s is_tax('hp_listing_tags') and overriding the page_title in the template context.

I can’t really find what you mentioned. I go through FTP to hivepress>templates>listing-category>page>page-title.php

But I don’t understand how to edit this code according to the screenshot I’ve sent where should I insert the prefix?
And will it change the title only for taxonomy “regions” or for all taxonomies?

Please try this PHP snippet, you can add it via the Code Snippets plugin:

add_filter(
	'hivepress/v1/templates/page',
	function( $args ) {
		if ( is_tax( 'hp_listing_region' ) ) {
			$region = get_queried_object();

			$args['context']['page_title'] = 'Region: ' . $region->name;
		}

		return $args;
	},
	1000
);

That work great! thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.