如何预填充wordpress全局选项设置字段?

如何预填充wordpress全局选项设置字段?,wordpress,Wordpress,我已经用下面的代码为我的wp主题创建了一个选项页面。它只是显示一个用户可以填写的消息文本区域。现在,如何在其中保留一个默认值,比如说“helloworld”,以便用户在填充和保存消息文本区域中的任何内容之前首先看到它 add_action('admin_menu', 'add_gcf_interface'); function add_gcf_interface() { add_options_page('Global Custom Fields', 'Global Custom Fi

我已经用下面的代码为我的wp主题创建了一个选项页面。它只是显示一个用户可以填写的消息文本区域。现在,如何在其中保留一个默认值,比如说“helloworld”,以便用户在填充和保存消息文本区域中的任何内容之前首先看到它

add_action('admin_menu', 'add_gcf_interface');

function add_gcf_interface() {
    add_options_page('Global Custom Fields', 'Global Custom Fields', '8', 'functions', 'editglobalcustomfields');
}

function editglobalcustomfields() {
    ?>
    <div class='wrap'>
    <h2>Global Custom Fields</h2>
    <form method="post" action="options.php">
    <?php wp_nonce_field('update-options') ?>

    <p><strong>Message</strong><br />
    <textarea name="message" cols="100%" rows="7"><?php echo get_option('message'); ?></textarea></p>


    <p><input type="submit" name="Submit" value="Update Options" /></p>

    <input type="hidden" name="action" value="update" />
    <input type="hidden" name="page_options" value="message" />

    </form>
    </div>
    <?php
}
add_操作('admin_菜单','add_gcf_界面');
函数add_gcf_interface(){
添加选项页面(“全局自定义字段”、“全局自定义字段”、“8”、“函数”、“editglobalcustomfields”);
}
函数editglobalcustomfields(){
?>
全局自定义字段
消息


我不确定我是否完全理解您的问题,但如果我理解正确,您希望在文本区域中有一个占位符(即在用户插入自己的文本之前出现在框中的默认文本?)

如果是这种情况,那么很简单,只需将占位符属性添加到textarea标记中,如下所示:

<textarea name="message" cols="100%" rows="7" placeholder="Hello World!">
   <?php echo get_option('message'); ?>
</textarea>