我想創建一個選項面板WordPress主題。選項頁面顯示正常,但是在提交表單時我得到:創建WordPress主題:
ERROR: options page not found.
這是我的代碼。
<?php
/*
Plugin Name: Option Man
Description: A test plugin to manage site
Author: Pravin Mishra
Version: 0.1
*/
add_action('admin_menu', 'test_plugin_setup_menu');
function test_plugin_setup_menu(){
add_menu_page('Option-Man-Plugin', 'Option Man', 'manage_options', 'test-plugin', 'test_init');
}
function test_init(){
add_action('admin_init', 'register_my_setting');
function register_my_setting() {
//register_setting('myoptions-group', 'my_option_name', 'intval');
register_setting(‘myoptions-group’, ‘testplugin_option1′);
register_setting(‘myoptions-group’, ‘testplugin_option2′);
}
\t echo "Hello world!";
\t ?>
<div class="wrap">
<u><h2>BS3 Custom Options</h2></u>
<form method="post" action="http://192.168.2.139/web/wp-admin/options.php">
<?php //settings_fields('myoptions-group');
//do_settings_sections('myoption-group');
settings_fields('myoptions-group');
\t \t \t \t ?>
<input type="text" name="testplugin-option1" value="<?php echo get_option('testplugin_option1'); ?>"/>
<input type="text" name="testplugin-option2" value="<?php echo get_option('testplugin_option2'); ?>"/>
\t \t \t \t <?php
\t \t \t submit_button();
?>
</form>
</div>
<?php
}
?>
現在感謝它的工作,但現在它不在wp_options表中插入值 –
您需要添加它。您沒有編寫任何代碼! –
但插入是由wordpress處理,我認爲 –