Remove the obligation to put a category in a listing

Hello,

For my site, I don’t need categories, and I’d just like to remove the requirement to put a category in the listings.

I already tried this code but it doesn’t work.

// Remove Category field from listing submit form
add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		unset($form['fields']['categories']);	

		return $form;
	},
	1000
);

Can you help me? I can’t find the php code for this. Thank you very much.

Thank you for waiting. Please try this PHP code snippet, but it can require further testing and customization.

add_filter(
	'hivepress/v1/models/listing',
	function( $args ) {
		$args['fields']['categories']['required'] = false;
		
		return $args;
	},
	1000
);

add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		unset($form['fields']['categories']);	

		return $form;
	},
	1000
);
2 Likes

Thank a lot. It’s work!

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