Reputation: 4728
I have created an Option page for my wp theme with following code. It just shows a message textarea which user can fill. Now how to keep a default value in it say "Hello World" so user sees it first before filling and saving anything in the message text area.
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
}
Upvotes: 0
Views: 116
Reputation: 632
Im not sure I fully understand your question, but if I have understood correctly, you are wanting to have a placeholder in your text area (i.e. default text that appears in the box prior to a user inserting their own text?).
If this is the case, then its quite simple, just add the placeholder attribute to your textarea tag as follows:
<textarea name="message" cols="100%" rows="7" placeholder="Hello World!">
<?php echo get_option('message'); ?>
</textarea>
Upvotes: 1