Last updated on : August 2, 2025
The Number field provides a single-line input that only accepts numeric values. It’s perfect for capturing quantities, IDs, prices, or any other numerical data.
Settings
- Field Type: Selects the type of input field to display. The Number field restricts input to numeric values only.
- Field Label: The label displayed above the input field on the form. Helps users understand what numerical value to enter.
- Field Name: A unique identifier used in the database and code. Only lowercase letters, numbers, and underscores are allowed. This value is used when retrieving and saving data.
- Required Field: Forces users to fill in this field before submitting the form. If enabled, empty or non-numeric values will not be accepted. Defaults to off.
- Default Value: Sets a pre-filled number that appears in the input when creating new entries. Users can adjust this as needed.
- Placeholder: Text that appears inside the input field when no value has been entered. It may serve as a visual hint like
123
or1000
.
Template usage
// Get the value of the Number field (replace 'number_field_key' with your actual field name)
$number_field_value = get_post_meta( $post->ID, 'number_field_key', true );
// Output the value (if it exists)
if ( is_numeric( $number_field_value ) ) {
echo '<p>Number: ' . esc_html( $number_field_value ) . '</p>';
}
That’s it! You’ve successfully configured a Number field. Now it’s ready to handle numeric input efficiently in your WordPress setup.