I have this code that adds a custom field to my products in woocommerce:
add_action( 'woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3 );
function shoptimizer_custom_author_field() { ?>
<?php if(get_field('author')) { ?>
<div class="cg-author"><?php the_field('author'); ?></div>
<?php }
}
Now I would want to add a condition to the if-statement that says "if field is not empty, hide product title".
The class for the product page product title seems to be "product_title".
Will be fascinating how this will look like once It’s added into this piece of code above. I think it’s not a big deal, but my comprehension ends with HTML and CSS sadly.
2
Answers
Just to conclude this thread, below anybody that seeks a similar answer can copy and paste the solution that worked for me:
I’m not sure if I understand your question correctly, but if you want to hide the product title if the custom field is not empty, you can use the following code:
If you want to hide the product title if the custom field is empty, you can use the following code: