0

I'm trying to understand creating custom plugin pages and menus in admin panel, but I get what I don't need. I've got:

function my_plugin_add_pages() {
   add_menu_page(__('Custom quiz', 'custom-quiz'), __('Custom quiz', 'custom-quiz'), 5, 'custom-quiz-listing-page', 'custom_quiz_list_page');
   add_submenu_page('custom-quiz-listing-page', __('Add quiz'), __('Add quiz'), 6, 'custom_quiz_add_quiz', 'custom_quiz_add_quiz');
   add_submenu_page('custom-quiz-listing-page', __('Edit quiz'), __('Edit quiz'), 6, 'custom_quiz_edit_quiz', 'custom_quiz_edit_quiz');
}

function custom_quiz_list_page() {
    require_once('includes/quiz-listing.php');
}

function custom_quiz_add_quiz() {
   if (!empty($_POST)) {
      CreateQuiz($_POST);
      echo '<meta http-equiv="refresh" content="0;url=?page=custom-quiz-listing-page" />';
   }
   require_once('includes/add-quiz.php');
}

function custom_quiz_edit_quiz() {
   if (!empty($_GET['quiz_id']) && !empty($_POST))
      UpdateQuiz($_POST);
   require_once('includes/edit-quiz.php');
}

And the problem is that all these pages (even subpages) are created in menu sidebar in admin panel. How to create page correctly without sticking it into admin menu?

1

I found the answer on Wordpress Forum: http://wordpress.org/support/topic/add-backend-page-without-menu-item#post-2135050

It requires add_submenu_page() with slug = null (first argument). In Wordpress documentation it's marked as 'required' so it looks like it's required but can be null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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