Limit the number of categories that vendor can select

Hi there, I’m using the ListingHive theme and I used the following code snippet from this forum (Allow selecting multiple categories) to allow for multiple categories that a vendor can select when doing Add Listing.

Now, I’m wondering if there is a way to limit the number of categories that a vendor can select, in my case, max 3 categories. Thank you in advance for assisting.


Unfortunately, there’s no such feature, it would require a custom implementation.

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work

Thanks Andrii for the tip. Did some trial&error using Search · user:hivepress · GitHub and HivePress Code Reference The following worked for me, thought i’d share:

Select Multiple Categories + Max 3 Categories + Placeholder on LISTING SUBMIT form: (replace ‘listing_submit’ with ‘listing_update’ to have the same thing for the editing form.

	function( $form ) {
			$form['fields']['categories']['multiple'] = true;	
            $form['fields']['categories']['max_values'] = 3;
		    $form['fields']['categories']['placeholder'] = 'max 3 categories';
		return $form;

1 Like

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