Hide categories when creating an ad

Hello yevhen, I have seen this excerpt that you wrote to help a user who wanted to hide a category when creating an ad.

It’s great. I need it too, but with a modification.

I have a category that in turn has two subcategories and I want to hide the main category when creating the ad, but that its two subcategories can be seen so that the user can select them.

Thank you very much.

add_filter(
	'hivepress/v1/models/listing/fields',
	function($fields, $model){
		$disabled_categories_ids = [1,2,3];
		
		if(isset($fields['categories']['options'])){
			foreach($disabled_categories_ids as $category_id){
				unset($fields['categories']['options'][$category_id]);
			}	
		}
		
		return $fields;
	},
	10000,
	2
);

Sorry, this would require further customizations, but users can’t select parent categories anyway, they have to choose a category that has no children so clicking on the parent category just opens its children list.

And is there a solution?

It’s just that my problem is that the drop-down looks very bad and all the categories and their categories come together and the user who puts ads I think that when he clicks on the categories he doesn’t select his category again so he does it wrong

It’s a drop-down system, it’s a bad system. It looks terrible.

We actually added this multi-step selection to improve the UX, instead of showing a single hierarchical list. Currently if a parent category is clicked, a list of child categories is opened and there’s an option to return to the parent list at the top, it’s the same as navigating folders in the file system. If you mean customizing this behaviour this would require advanced customizations. There may be also an option to return to the old hierarchical list if this helps.

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