Category filter in search bar - Requests search page

Hello,

I was wondering if it’s possible to add the Category filter to the search bar in the Requests search page like it’s possible to do in the Listings search page?

Here’s the discussion I had with Ihor by email that led me to write this Topic.

Me : Put the category filter for the Requests in the search bar instead of the sidebar like it’s possible for the Listings.
Ihor : It should be already possible, please let me know if the Category field is missing in the Default Fields in HivePress/Settings/Requests.
Me : I confirm that the Category field is missing. Is there something I can do to make it appear?
Ihor : In this case please post a new topic on the forum and our developer will also provide a temporary fix until we release the Requests update.

Thank you for your support
Philippe

Please try this PHP snippet

add_filter(
	'hivepress/v1/forms/request_search',
	function ($form){
		$form['fields']['_category'] = array_merge(
			$form['fields']['_category'],
			[
				'type' => 'select',
				'placeholder'  => 'All Categories',
				'options'      => 'terms',
				'option_args'  => [ 'taxonomy' => 'hp_request_category' ],
				'_order'       => 20,
			]
		);
		
		return $form;
	},
	1000
);

Thank you, it worked!
However, how do I do to remove the Category filter from the sidebar now?

Please try this PHP snippet

add_filter(
	'hivepress/v1/forms/request_filter',
	function ($form){
		unset($form['fields']['_category']);
		
		return $form;
	},
	1000
);

Awesome, thank you!

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