Hi Neil,
Question #1 – how can I implement fields that recognize numerical input as a percentage? I am using the number field now….
It actually doesn't. You need to write some description to the field to let users know it's a percentage.
Question #2 – how do I perform calculations and then display the result?
When you insert the code to the front end, please add some calculation before that:
$value = rwmb_meta( 'percentage' );
$value = $value / 100 * $another_field_value;
echo $value;
If you're using a page builder like Beaver Builder, I'd suggest writing a custom shortcode to put into a text module in BB. The shortcode might be like this (put in functions.php
):
add_shortcode( 'your_percentage', function( $atts, $content ) {
$value = rwmb_meta( 'percentage' );
$value = $value / 100 * $another_field_value;
return $value;
} );
In a text module in BB, simply insert [your_percentage]
and your result will appear.