customization - Admin only menupage

Is it possible to show a menu item If only admin is logged in)For any other user the menu item does not appear.For examp

Is it possible to show a menu item If only admin is logged in)

For any other user the menu item does not appear.

For example: if there are a few pages that have shortcodes or other functionality exampled to show how to build toggles etc, but only want the admin to be able to see them. These pages generally come with pre-built themes and show the admin how to build pages within the site.

By hiding the menu items, a series of pages can be "hidden" from a user but allow the admin to see them to be able to build pages, without having to remove them entirely from the site

:P make sense?

Is it possible to show a menu item If only admin is logged in)

For any other user the menu item does not appear.

For example: if there are a few pages that have shortcodes or other functionality exampled to show how to build toggles etc, but only want the admin to be able to see them. These pages generally come with pre-built themes and show the admin how to build pages within the site.

By hiding the menu items, a series of pages can be "hidden" from a user but allow the admin to see them to be able to build pages, without having to remove them entirely from the site

:P make sense?

Share Improve this question asked Jul 12, 2013 at 20:39 idarylidaryl 111 silver badge2 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Yes, it is possible.

You could use wp_nav_menu_objects or wp_nav_menu_items hooks to add your filter function.

function my_hide_menu_items($objects) {
    if ( is_admin() ) return $objects;

    foreach ( $objects as $k=>$object ) {
        if ( YOUR CONDITION ) {  // if $object shouldn't be displayed
            unset($objects[$k]);
        }
    }
    return $objects;
}
add_filter('wp_nav_menu_objects', 'my_hide_menu_items', 10, 2);

You can also use this plugin: http://wordpress/plugins/menu-items-visibility-control/ (I haven't tested it, so I'm not sure if it really works).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745331941a4622921.html

相关推荐

  • customization - Admin only menupage

    Is it possible to show a menu item If only admin is logged in)For any other user the menu item does not appear.For examp

    8小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信