[英]Error: options page not found in Wordpress Plugin
When developing a plugin, using the Settings API do create an options page many developers get this message after saving the options and posting to "options.php" 在开发插件时,使用Settings API确实创建了一个选项页面,许多开发人员在保存选项并发布到“options.php”后收到此消息
Error: options page not found in Wordpress Plugin
Even adding a function to register this settings like: 甚至添加一个功能来注册这个设置,如:
function pg_register_settings()
{
add_settings_section(
'setting_section_oauth', // ID
'Instagram API Client Info', // Title
array( $this, 'print_section_oauth_info' ), // Callback
$this->plugin_slug.'-setting-admin' // Page
);
add_settings_field(
'key', // ID
'Application Key', // Title
array( $this, 'field_key_callback' ), // Callback
$this->plugin_slug.'-setting-admin', // Page
'setting_section_oauth' // Section
);
register_setting( 'bitloom-instagram-options', 'key' );
}
And using the code below on the form 并在表单上使用下面的代码
<form method="post" action="options.php">
<?php
settings_fields( 'bitloom-instagram-options' );
do_settings_sections( 'bitloom-instagram-setting-admin' );
submit_button();
?>
</form>
Whats is missing? 什么不见了?
您需要使用admin_init挂钩注册设置,否则它将无法工作。
add_action( 'admin_init', 'pg_register_settings' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.