My theme currently uses add_menu_page() in order to display the theme options sections on the left hand admin menu.

I would like to be able to attach a parent css class to the main menu item in order to selectively show/hide the menus for advanced users.

I don't see this documented in the codex so I'm asking here to find out if there is a workaround or undocumented feature that I can utilize.

Any help, much appreciated.

The basic idea is that I have one main menu item and about 8 submenu items. Currently, all the menu items are displayed in the menu. I would like to use custom css to toggle the visibility of the submenu items, however, there is currently no custom id or class that I can use to target my menus.

  • I don't get where exactly you want the classes. Can you post the base of your code? And detail the submenu behavior?
    – brasofilo
    Mar 26, 2013 at 15:17

1 Answer 1


You should not do this via CSS as the underlying functionality would still be there (and thus open for direct access).

I'd rather rewrite the theme in a way that the menu pages are only added if the current user has a certain capability.

if (current_user_can( SOME_CAP )) {
    add menu pages ...

You could even provide a new capability for your theme. Have a look over here, if you're interested in this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.