// editor role - add appearance menu
$role_object = get_role( 'editor' );
// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );
Use the relatively new Wordpress Menu feature instead.
Add the following register_nav_menu function to your functions.php file.
add_action( 'after_setup_theme', 'template_setup' );
if ( ! function_exists( 'template_setup' ) ):
function template_setup() {
// register nave menu
register_nav_menu('primary','Main Menu');
}
endif;
If you already have a function that fires on 'template_setup', the just add the following line to that function:
register_nav_menu('primary','Main Menu');
Then in your header.php (or where ever you want the menu to appear) add the call to wp_nav_menu:
Then log in to your Wordpress Admin area, with a username that has Admin privileges. Goto Appearance > Menus (this is a new page that will be accessible, after registering the menu in your functions.php file).
Create a new menu, call it what you like, and assign it to the theme location, in this case 'Main Menu'. Here you can now build your menu from any pages, posts, categories etc. that are in your wordpress installation. Also included is a handy link to 'Home'. For more information on the interface see here.
The interface is lovely as well, nice drag and drop and the additional benefit of your menu remaining the same, even when you add new pages.
/
Also if you want users who aren't Admin's, but who are 'Editors' to be able to edit the menu, add the following to your functions.php file.
// editor role - add appearance menu
$role_object = get_role( 'editor' );
// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );
发布评论
评论(1)
请改用相对较新的 WordPress 菜单功能。
将以下 register_nav_menu 函数添加到您的functions.php 文件中。
如果您已经有一个在“template_setup”上触发的函数,只需将以下行添加到该函数中:
然后在 header.php 中(或您希望菜单出现的任何位置)添加对 wp_nav_menu:
然后使用具有管理员权限的用户名登录到您的 WordPress 管理区域。转到外观>菜单(这是一个新页面,在functions.php 文件中注册菜单后即可访问)。
创建一个新菜单,将其命名为您喜欢的名称,并将其分配给主题位置,在本例中为“主菜单”。在这里,您现在可以从 WordPress 安装中的任何页面、帖子、类别等构建菜单。还包括一个指向“主页”的便捷链接。有关界面的更多信息,请参阅此处。
界面也很可爱,拖放效果很好,而且即使添加新页面,菜单的额外好处也保持不变。
/
另外,如果您希望非管理员但“编辑者”的用户能够编辑菜单,请将以下内容添加到您的functions.php 文件中。
Use the relatively new Wordpress Menu feature instead.
Add the following register_nav_menu function to your functions.php file.
If you already have a function that fires on 'template_setup', the just add the following line to that function:
Then in your header.php (or where ever you want the menu to appear) add the call to wp_nav_menu:
Then log in to your Wordpress Admin area, with a username that has Admin privileges. Goto Appearance > Menus (this is a new page that will be accessible, after registering the menu in your functions.php file).
Create a new menu, call it what you like, and assign it to the theme location, in this case 'Main Menu'. Here you can now build your menu from any pages, posts, categories etc. that are in your wordpress installation. Also included is a handy link to 'Home'. For more information on the interface see here.
The interface is lovely as well, nice drag and drop and the additional benefit of your menu remaining the same, even when you add new pages.
/
Also if you want users who aren't Admin's, but who are 'Editors' to be able to edit the menu, add the following to your functions.php file.