我想創建一個插件我得到的錯誤:您沒有足夠的權限訪問此頁。有2個文件 buffer.php bufferpage.php如何創建WordPress的管理菜單和鏈接到頁面
我已經創建管理菜單,但我想顯示/在右側顯示「bufferpage.php」 後點擊子菜單命名子菜單-3
但notworking :(
buffer.php 在這裏
//Register the main menu name 「buffercode_menu」
add_action('admin_menu', 'buffercode_menu');
//adding menu menu in wordpress admin panel
function buffercode_menu() {
add_menu_page('BufferCode plugin page', 'Menu plugin settings','manage_options', __FILE__,'buffercode_plugin',plugins_url('/images/menu-icon.png', __FILE__));
//submenu
add_submenu_page(__FILE__, 'BufferCode Submenu','Submenu-1', 'manage_options',__FILE__.'_menu1', buffercode_plugin);
add_submenu_page(__FILE__, 'BufferCode Submenu','Submenu-2', 'manage_options',__FILE__.'_menu1', buffercode_plugin);
add_submenu_page(__FILE__, 'BufferCode Submenu','Submenu-3', 'manage_options',__FILE__. $view_level, 'bufferpage.php');
}
這裏是bufferpage.php
<div class="wrap">
<?php echo "<h2>" . __('Sample page', 'buffercode_menu') . "</h2>"; ?>
<?php
global $wpdb;
/* wpdb class should not be called directly.global $wpdb variable is an instantiation of the class already set up to talk to the WordPress database */
$result = $wpdb->get_results("SELECT * FROM wp_savans "); /*mulitple row results can be pulled from the database with get_results function and outputs an object which is stored in $result */
//echo "<pre>"; print_r($result); echo "</pre>";
/* If you require you may print and view the contents of $result object */
?>
<table width="100%" border="1">
<tr>
<td width="116" align="center" bgcolor="#FFFF99"><strong>Name</strong></td>
<td width="146" align="center" bgcolor="#FFFF99"><strong>Email</strong></td>
</tr>
<?php
foreach($result as $row)
{
echo "<tr align=center>
<td>$row->name</td>
<td>$row->email</td>
</tr>";
}
/* Print the contents of $result looping through each row returned in the result */
?>
</table>
</div>
不工作 後添加此我得到這樣的鏈接: HTTP:/ /localhost/student/wordpress/wp-admin/admin.php?page=customplugin/index.php – vivek
試試我更新的答案... –
非常非常感謝y ou ............. @Akshay是它的工作:) 你能告訴我如何添加兩個子菜單? – vivek