First time making a custom plugin so please go easy on me! I'm attempting to build a custom plugin with an admin panel. I have created the menu without too much trouble, but I'm now struggling to make the submenu work the way I want it to.

My plugin structure is like this:
- my-plugin
-- index.php
-- admin
--- submenu-page.php

My code looks as follows:

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
    add_menu_page('WISE Admin', 'WISE Admin', 'manage_options', 'wise-menu', 'my_menu_output', 'dashicons-tickets', 2 );
    add_submenu_page('wise-menu', 'General Settings', 'General', 'manage_options', 'general-settings', 'general_settings' );
    remove_submenu_page('wise-menu', 'wise-menu');

function general_settings(){
    include(plugin_dir_path( __FILE__ ).'admin/submenu-page.php');

Unfortunately, the page loads as a blank even if I simply echo 'Hello World'. Can someone explain what I am doing wrong?

  • in my_menu_pages function you remove your own sub menu. can you remove remove_submenu_page('wise-menu','wise-menu') and try again. also you can check – Serkan Algur Nov 27 at 23:04
  • @SerkanAlgur I have pored over that page many times but couldn't understand why my function wasn't working. I will try changing my code as you say but I added the 'remove_submenu_page' to only remove the first submenu item as it is a repeat of the parent menu item. – user1192309 Nov 28 at 11:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.