我正在创建一个主题选项页面,并尝试在前端显示两个输入值:
function register_my_header() {
register_setting( \'header_options\', \'header_options\');
}
add_action(\'admin_init\', \'register_my_header\');
function add_header_settings() {
add_menu_page(\'Options header\', \'Options header\', \'manage_options\', \'edit_header\', \'header_edit_page\', null, 58);
}
add_action(\'admin_menu\', \'add_header_settings\');
function header_edit_page() {
?>
<div id="theme-options-wrap">
<div class="icon32" id="icon-tools"> <br> </div>
<h2>Header Options</h2>
<p>Description</p>
<?php
if ( false !== $_REQUEST[\'updated\'] ) : ?>
<div><p><strong><?php _e( \'Options saved\' ); ?></strong></p></div>
<?php endif; ?>
<form method="post" action="options.php">
<?php settings_fields(\'header_options\'); ?>
<?php $options = get_option(\'header_options\'); ?>
<table class="form-table">
<tr>
<th scope="row">Mail</th>
<td>
<input type="text" name="header_options[txt_mail]" value="<?php echo $options[\'txt_mail\']; ?>" />
</td>
</tr>
<tr>
<th scope="row">Phone number</th>
<td>
<input type="text" name="header_options[txt_number]" value="<?php echo $options[\'txt_number\']; ?>" />
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e(\'Save Changes\') ?>" />
</p>
</form>
</div>
<?php
}
function header_validate_options($input) {
$input[\'txt_mail\'] = wp_filter_nohtml_kses($input[\'txt_mail\']);
$input[\'txt_number\'] = wp_filter_nohtml_kses($input[\'txt_number\']);
return $input;
}
function header_add_content() {
$options = get_option(\'header_options\');
}
add_filter("the_content", "header_add_content");
我可以保存该值,但当我调用它时: <div class="background-content"></div>
<div class="layout-header">
<h1 id=\'logo\' class="image-logo">
<a href="<?php echo home_url(); ?>"><img <?php do_shortcode(\'[sitelogo]\'); ?></a>
</h1>
<div id="contact">
<p>Contact Us</p>
<p><?php echo $options[\'txt_mail\']; ?></p><p><?php echo $options[\'txt_number\']; ?></p>
</div>
</div>
要在前面显示它,什么都不会发生!我做错了什么?