How to index tags for the search bar?

Would it be possible to write a snippet to index tags for the search bar?

Hi,

Please try this PHP snippet, once you add it and re-save some listings then, its tags will be indexed in the keyword search (How to add custom code snippets - HivePress Help Center):


add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['tags'] ) ) {
			$attributes['tags']['indexable'] = true;
		}

		return $attributes;
	},
	1000
);

Please note that it can require further customization.

‚ÄčI hope this is helpful to you.

Hi Andrii,

I appreciate the response. I have added the PHP snippet and re-saved listings, however it does not return any search results when I lookup specific tags I know I have added to a listing. Is there anything else I could try?

Kind regards,
Tony

Hi,

We checked this PHP from our side, and it seems okay.

Please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, make sure that caching is disabled for logged-in users.

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