Skip to content

Section

Radoslav Georgiev edited this page Oct 21, 2018 · 2 revisions

Purpose

Sections allow you to visually separate fields by their purpose.

sections

They have no purpose data- & field-wise and no values will be saved for them.

Sections support:

  • Title: The label of the section will be used for its title.
  • Text: The description of the field will be displayed below the title of the section if entered.
  • Icons: You can choose an icon, which will appear next to the title of the section.
  • Backgrounds: There are multiple (fixed) options for the background of the section.

Here is how to create a basic section:

Field::create( 'section', 'basic_fields', 'Section title' )
	->set_description( 'This description will be shown on a new row with normal font.' )

Settings

All of the settings, described below are marked clearly in the settings of the section in the interface.

Icon

You can use Dashicons to display an icon before the title of the section. Use the set_icon method for that. It accepts a single parameter, which should be the icon CSS class.

Field::create( 'section', 'basic_fields' )
	->set_icon( 'dashicons-calendar' )

Color

You can use the set_color method to change the background of the section.

Supported options are:

  • white (default)
  • blue
  • red
  • green
Field::create( 'section', 'basic_fields' )
	->set_color( 'blue' )

Usage

Because of the fact that sections do not save any values, you cannot use them in the front-end.

Clone this wiki locally