Join our new community forum for support & discussion

Join Now

Home Support Extensions Geolocation Hide Open Now from filter in certain categories

Hide Open Now from filter in certain categories

  • Author
    Posts
  • alexif

    Hi!

    How can I hide the open now filter from the side bar in certain categories?

    I have categories which do not have applicable opening hours and would like to not influence filtering.

    Thanks!

    yevhen developer

    Please try this PHP snippet. Please change [1,2,3] with categories id where you want to show Open now checkbox

    add_filter(
    	'hivepress/v1/forms/listing_filter',
    	function( $form_args, $form ) {
    		$listing_category = hivepress()->request->get_context('listing_category');
    		
    		if($listing_category && !in_array($listing_category->get_id(), [1,2,3])){
    			unset($form_args['fields']['_open']);
    		}
    
    		return $form_args;
    	},
    	1000,
    	2
    );
    
    add_filter(
    	'hivepress/v1/forms/listing_sort',
    	function( $form_args, $form ) {
    		$listing_category = hivepress()->request->get_context('listing_category');
    		
    		if($listing_category && !in_array($listing_category->get_id(), [1,2,3])){
    			unset($form_args['fields']['_open']);
    		}
    
    		return $form_args;
    	},
    	1000,
    	2
    );
Viewing 2 posts - 1 through 2 (of 2 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.