Show zero value with ACF from backend to frontend in Generateblocks

[ad_1]

Show zero value with ACF from backend to frontend in Bricks builder, Generateblocks and Elementor Hello, the problem is replicated in everyone and I think it has to do with ACF and its fields, with ACF in the backend in the numeric or text fields, if I fill them with a single zero value, it does not show me anything in the frontend and I What I want is that if I write zero in the field it shows me zero and if I write nothing it shows nothing, how can I solve this error? This error appears if I use dynamic fields from Bricks builder, Generateblocks and Elementor, with the shortcode [acf field="field_name" post_id="123"] works fine, but this shortcode does not work in the wordpress query loop generated by Bricks builder, Generateblocks and Elementor.

Product evaluation example:

Backend value acf_field = 2 Frontend value = 2/10

Backend value acf_field = 5 Frontend value = 5/10

Backend value acf_field = 0 Frontend value = /10

It should be like that:

Backend value acf_field = 0 Frontend value = 0/10

Backend value acf_field = Frontend value = /10

Thank you so much

`function display_zero_if_value_is_zero( $value, $post_id, $field ) {
// Check if the field value is "0" and not empty
if ( $value === '0' && ! empty( $value ) ) {
return '0';
}

    return $value;

}

add_filter( 'acf/format_value', 'display_zero_if_value_is_zero', 10, 3 );`

This, like several similar functions, did not work.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer