我想创建一个插件我得到的错误:您没有足够的权限访问此页。有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