Hi,
hmm so if i understand correctly, when Ad is assigned to the category with id 568 the empty price text should show?
If so then you should be able to do that using the code below
add_filter( "get_post_metadata", function( $value, $object_id, $meta_key ) {
if( ! is_singular( 'advert' ) && ! is_page( adverts_config( "ads_list_id" ) ) ) {
return $value;
}
if( $meta_key == "adverts_price" ) {
$terms = wp_get_post_terms( $object_id, 'advert_category', array( 'fields' => 'ids' ) );
if(in_array( 568, $terms )) {
return 0;
}
}
return $value;
}, 10, 3 );
If you want to differentiate between empty price and Ad assigned to category with ID 568 then you can change line return 0;
to return -1
and additionally use the below code
add_filter( "adverts_get_the_price", function( $price, $price_raw, $post_id ) {
if( $price_raw == -1 ) {
$price = "Negotiable.";
}
return $price;
}, 1000, 3 );