[英]Wordpress error “You do not have sufficient permissions to access this page.” on adding a theme option page
我正在為我的客戶開發一個主題設置頁面。 我想添加一個主題選項頁面以應用設置,但出現Wordpress錯誤“您沒有足夠的權限訪問此頁面。我認為我使用的是正確的代碼,但問題仍然存在。請幫助我確定我的位置錯誤
/*
* ADD THEME SETTINGS PAGE
*/
function vc_add_theme_settings_page(){
add_theme_page('Theme Settings','Theme Settings', 'manage_options' , 'vc_theme_page', 'vc_theme_page_display' );
}
add_action('admin_init', 'vc_add_theme_settings_page');
/*
* DISPLAY THEME SETTINGS PAGE
*/
function vc_theme_page_display(){
?>
<div class="wrap">
<h2>Vc Theme Settings Page</h2>
<form action="options.php" method="POST">
<?php settings_fields('vc_section'); ?>
<?php do_settings_sections('vc_theme_page'); ?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
通過以下方式訂購代碼:
add_action('admin_menu', 'vc_add_theme_settings_pages');
add_action('admin_head', 'theme_styles');
add_action('admin_init', 'vc_add_theme_settings_page');
function vc_add_theme_settings_page(){
add_theme_page('Theme Settings','Theme Settings', 'edit_theme_options', 'manage_options', 'vc_theme_page_display' );
}
嘗試改變
<?php do_settings_sections('vc_theme_page'); ?>
對於
<?php do_settings_sections(__FILE__); ?>
add_action('admin_init', 'vc_add_theme_settings_page'); //instead of this
add_action('admin_menu', 'vc_add_theme_settings_page'); //try this
希望它對您有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.