0

I have a custom post type called "Product" and I have ACF relationship field called meta_product_hands_on_review to pull related review posts in the product.

I would like to hide a link "Read Hands On Review" in a product box, if the relationship field is empty. Product box screenshot

I tried using a dynamic condition plugin but they don't support relationship field for dynamic tags.. Elementor admin screen with the plugin

It would be great if I can achieve this without using any plugins! I use code snippet and if anyone can help me with custom php code that I can add to my code snippet, it would be amazing!

1 Answer 1

0

You would use an if statement to check whether the field is empty or not. If the field is empty, it will not show anything. If the field has data, put what you want to show in the else section of the conditional statement.

$acfField = get_field( 'meta_product_hands_on_review' );
if ($acfField) {
   return;
} else {
   // Show the field here
}

Here is more about hiding fields with ACF: https://www.advancedcustomfields.com/resources/hiding-empty-fields/

Not the answer you're looking for? Browse other questions tagged or ask your own question.