Reputation: 33
I'm sure this is an easy question but I am a beginner. I've figured out how to display my ACF info (woohooo) but if the field is blank the echo needs to be removed. I am not sure how to go about adding that in.
add_action( 'woocommerce_single_product_summary', "ACF_product_content", 5 );
function ACF_product_content(){
if (function_exists('the_field')){
echo '<h2 class="dd-tiff">Delivery Date: ';
the_field('ti-date');
echo '</h2>';
}
}
Upvotes: 0
Views: 105
Reputation: 521
add_action( 'woocommerce_single_product_summary', "ACF_product_content", 5);
function ACF_product_content(){
if (function_exists('the_field')){
if(!is_null(the_field('ti-date')) || strlen(the_field('ti-date')) != 0){
echo '<h2 class="dd-tiff">Delivery Date: ';
the_field('ti-date');
echo '</h2>';
}
}
}
Upvotes: 0
Reputation: 609
add_action( 'woocommerce_single_product_summary', "ACF_product_content", 5 );
function ACF_product_content(){
if (function_exists('the_field')){
$ti_date = get_field('ti-date');
if($ti_date){
echo '<h2 class="dd-tiff">Delivery Date: ';
the_field('ti-date');
echo '</h2>';
}
}
}
Try this code
Upvotes: 2