Hide primary listing attributes for specific categories

You can try this one, but please note that it’s not tested:

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields, $model ) {
		if ( isset( $fields['price'] ) ) {
			$category_ids=wp_get_post_terms( $model->get_id(), 'hp_listing_category', array( 'fields' => 'ids' ) );

			if(in_array(56, $category_ids)) {
				// Replaces the price with the word "Gift"
				$fields['price']['display_template'] = 'Gift';
			}
		}
		return $fields;
	},
	1000,
	2
);

Please consider hiring a developer if further code customizations are needed Experts | HivePress While we can provide general guidance, customizations of the existing functionality are beyond the support scope.

1 Like