Hello all, I am trying to copy one specific attribute I have set up in Listings to Requests attributes. This attribute has 10 checkbox categories within.
I am trying with the following code but it’s not working.
function duplicate_service_offered_attribute() {
if ( function_exists( 'hivepress' ) ) {
$attributes = hivepress()->get_attributes();
// Get the existing "Service Offered" attribute
$existing_attribute = $attributes->get( 'service_offered' );
if ( $existing_attribute ) {
// Clone the attribute and modify its properties
$new_attribute = $existing_attribute;
$new_attribute['name'] = 'Requested Service'; // New attribute name
$new_attribute['slug'] = 'requested_service'; // Unique slug
$new_attribute['listing_section'] = 'requests'; // Assign to requests
// Register the new attribute
$attributes->set( 'requested_service', $new_attribute );
}
}
}
add_action( 'init', 'duplicate_service_offered_attribute' );
Any leads?
thank you