0

I created a settings page that's being displayed in the options menu like this:

add_options_page(
    'ATB Event Options',
    'ATB Event Options',
    'manage_options',
    'atb-event-options',
    'atb_event_options_display'
);

Instead, I'd like to display it as a menu item under another parent menu with the slug 'mvc_events':

add_submenu_page(
    'mvc_events',
    'ATB Event Options',
    'ATB Event Options',
    'manage_options',
    'atb-event-options',
    'atb_event_options_display'
);

While that does add "ATB Event Options" to my mvc_events menu, it overwrites the first menu item I had there, and the link doesn't even work. The link is generated as blah.dev/wp-admin/atb-event-options.

Any idea what I'm doing wrong?

1 Answer 1

1

You'd need to create the top-level menu page, and then the sub-menu after that.

Here's an example:

function my_menu() {
  add_menu_page ( 
    'MVC Events',      // $page_title
    'MVC Events',      // $menu_title
    'manage_options',  // $capability
    'mvc-events',      // $menu_slug
    'mvc-options'      // $function
    );
  add_submenu_page (
    'mvc-events',         // $parent_slug
    'ATB Event Options',  // $page_title
    'ATB Event Options',  // $menu_title
    'manage_options',     // $capability
    'atb-event-options',  // $menu_slug
    'atb-options'         // $function
    );
  }
add_action( 'admin_menu', 'my_menu' );

Here's the pertinent WP codex file, and one particularly on sub-menus.

2
  • Yeah, but I'm using WP-MVC which generates menus by default and I can't override it. So I'm guessing I'm screwed.
    – dallen
    Aug 7, 2013 at 2:26
  • Gotcha. Yeah, I'd suggest contacting Tom Benner, the developer, directly then. His contact is available online.
    – bulldog
    Aug 7, 2013 at 17:42

Your Answer

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

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