Hi!
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!)
add_filter(
'hivepress/v1/models/listing/attributes',
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;
},
1000
);