Restrict location for a specific category

hi I wanted to know it is possible to display location for a specific category when adding an ad for example location is displayed only for the category “service”

Hi,

Please check this topic Show location only for specific categories

​I hope this is helpful to you.

hi
I replaced with the category slug, it gave me a fatal error

$categories = [ 1, 2, 3 ]; by $categories = [ real-estate ];

the code in question

<?php
add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['location'] ) ) {
			$categories = [ real-estate ];

			$attributes['location']['categories']  = $categories;
			$attributes['latitude']['categories']  = $categories;
			$attributes['longitude']['categories'] = $categories;
		}

		return $attributes;
	},
	1000
);

Hi,

You need to specify the category ID, and you have specified the slug.

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