I am adding some settings to the "General" settings page:
add_settings_section(
'foobar_settings_section',
'Foobar Options',
[$this, 'foobar_options_callback'],
'general'
);
$fields = [
'foobar_title' => 'Title',
'foobar_link' => 'Link',
// lots more
];
foreach ($fields as $fieldKey => $fieldTitle) {
add_settings_field(
$fieldKey,
$fieldTitle,
[$this, 'foobar_textbox_callback'],
'general',
'foobar_settings_section',
[$fieldKey]
);
register_setting('general', $fieldKey, 'esc_attr');
}
This just outputs a column of many input
fields, which functionally is fine. But it makes for confusing UX. Is there a way to generally make this section prettier? E.g. to divide it into subsections, or into columns?
I am adding some settings to the "General" settings page:
add_settings_section(
'foobar_settings_section',
'Foobar Options',
[$this, 'foobar_options_callback'],
'general'
);
$fields = [
'foobar_title' => 'Title',
'foobar_link' => 'Link',
// lots more
];
foreach ($fields as $fieldKey => $fieldTitle) {
add_settings_field(
$fieldKey,
$fieldTitle,
[$this, 'foobar_textbox_callback'],
'general',
'foobar_settings_section',
[$fieldKey]
);
register_setting('general', $fieldKey, 'esc_attr');
}
This just outputs a column of many input
fields, which functionally is fine. But it makes for confusing UX. Is there a way to generally make this section prettier? E.g. to divide it into subsections, or into columns?
1 Answer
Reset to default 0At the moment, this is not possible.
Just create your own custom settings page and place your options to it.
More details and examples: https://blog.templatetoaster/wordpress-settings-api-creating-theme-options/