Hello,
Do you try to combine the code? Replacing the echo
state with return
? For example:
add_filter( 'rwmb_meta', function( $value, $field_id, $args, $object_id ) {
if ( $field_id == 'number' ) {
$value = number_format( $value, 3, '.', ',' );
$value = rtrim( $value, '0.' );
}
return $value;
}, 10, 4 );
Also, this filter will work when you call the function rwmb_meta()
to display the value on the frontend. It will not work with other page builders if they are getting field value from the database.
So I don't think there is a difference between using the code to echo
field value on the frontend with the filter.