Join our new community forum for support & discussion

Join Now

Home Support Themes RentalHive Hide price + booking from listing category

Hide price + booking from listing category

  • Author
  • rachelle


    I found the following code snippet amongst the forum. It’s to hide the price field and the booking capabilities for certain categories. I’ve tried to use it by including my own category IDs but… I don’t think I’m writing it out correctly. I’m supposed to change the 1,2,3 to my category IDs, but I don’t know where to find those. I can only find the category slugs and category names (and I’m not 100% sure how to include those in the code: adding them in quotes, no quotes, etc.)

    For example, let’s say I have categories called “homes”, “cottages” and “example”. I only want to hide bookings and prices from “example” category. How should I replace 1,2,3? (sorry if this is a dumb question!)

    	function( $attributes ) {
    		$category_ids = [ 1, 2, 3 ];
    		if ( isset( $attributes['price'] ) ) {
    			$attributes['price']['categories'] = $category_ids;
    		if ( isset( $attributes['booking_offset'] ) ) {
    			foreach ( $attributes as $name => $args ) {
    				if ( strpos( $name, 'booking' ) === 0 ) {
    					$attributes[ $name ]['categories'] = $category_ids;
    		return $attributes;
    yevhen developer

    Please open a category to edit and you will see the category ID in the link of the page. Category ID is the number between ‘category&tag_ID=’ and ‘&post_type’ in link

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.