最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Customize format of settings

programmeradmin3浏览0评论

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?

Share Improve this question asked Apr 1, 2020 at 12:57 GluePearGluePear 1133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

At 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/

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论