Numeric

The numeric lets you add a field for number.

Numeric

Parameters

Here are the parameters in adding numeric.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | requiredl

the section where the field will be displayed.

default
integer | optional

the default value of the field.

priority
integer | optional

determines the order of fields in section.

options
array | optional

set of options.

options['min']
integer | required

minimum value set.

options['max']
integer | required

maximum value set.

options['step']
int | optional

stepper value.

Example


Yano::field( 'numeric', [
   'id'          => 'numericdb1',
   'label'       => 'Enter Number',
   'description' => 'Some description',
   'section'     => 'section_id',
   'priority'    => 1,
   'options' => [
      'min'  => 0,
      'max'  => 100,
      'step' => 1
   ]
] );

Example with default value! note: default value must be numeric type.


Yano::field( 'numeric', [
   'id'          => 'numericdb1',
   'label'       => 'Enter Number',
   'description' => 'Some description',
   'section'     => 'section_id',
   'default'     => 50,
   'priority'    => 1,
   'options' => [
      'min'  => 0,
      'max'  => 100,
      'step' => 1
   ]
] );

Usage

The get_theme_mod() function is recommended to retrieve data.


// Return a integer
echo get_theme_mod('numericdb1');