首页 > 解决方案 > 您如何使用 wordpress 选项 API 为插件设置选项页面的样式?

问题描述

我正在编写我的第一个 wordpress 插件。我使用 wordpress 选项 API 函数add_settings_section()add_settings_field().

到目前为止一切正常,但设置页面上的所有字段都在一列中。我想将选项页面的样式设置为“更好”一点,但我找不到它的 API。

例如,如何使用<div>html将设置部分和设置字段排列在两列中<table>?wordpress API 似乎创建了自己的表结构。

谢谢!

标签: wordpresswordpress-plugin-creationwordpress-admin

解决方案


这是我处理相同问题的方法。
在这里给出上下文是我想要的列的图像。 在此处输入图像描述

在我的实现中,我删除do_settings_sections('my_page'); 并使用了原始 HTML。

<form action="options.php" method="post">
<?php
settings_errors();
settings_fields('my_page_settings');
// do_settings_sections('my_page');
?>

<table class="form-table">

    <tr>
        <th scope="row">Update Mode</th>
        <td><?php $this->my_page_render_update_mode_field() ?></td>
    </tr>
    <tr>
        <th scope="row">Update</th>
        <td style="padding-top:0px !important;">
            <table class="form-table">
                <tr>
                    <td style="padding-top:0px !important;"><?php $this->my_page_render_page_items_field() ?></td>
                    <td style="padding-top:0px !important;"><?php $this->my_page_render_post_field() ?></td>
                    <td style="padding-top:0px !important;"><?php $this->my_page_render_product_items_field() ?></td>
                </tr>

            </table>
        </td>

    </tr>
</table>
<input type="submit" style="margin-bottom:10px !important;" name="submit" class="button button-primary button-md" value="<?php esc_attr_e('Save'); ?>" />

推荐阅读