WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '13 at 15:17
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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