PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

[FIXED] Why won't this submenu page show? - My First WordPress Plugin

 February 05, 2022     php, wordpress, wordpress-plugin-creation     No comments   

Issue

Starting to build my first plugin and I'm completely puzzled on why the submenu page won't show? The main page shows up, not the subpage.

I've run over the syntax what feels like a million times and I just don't see the gap on what I have here. (Page markup is complete, not shown, I'm just trying to get the menu item to show up.)

/* Create Menu Item */
function core_settings_menu() {

    add_menu_page(
        'Core Settings & Code Manager',
        'Core Settings',
        'manage_options',
        'core-settings-page',
        'core_settings_page_contents',
        'dashicons-superhero',
        90
    );

    add_submenu_page(
        'core-settings-page',
        'Code Snippets',
        'manage-options',
        'core-settings-code-snippets',
        'core_settings_code_snippets_markup'
    );

}

 /* Add Menu To Site */
 add_action( 'admin_menu', 'core_settings_menu' );

Solution

You are missing the thrid menu_title argument, and you also have a typo in the manage-options. Should be manage_options

add_submenu_page(
        'core-settings-page',
        'Code Snippets',
        'Code Snippets',
        'manage_options',
        'core-settings-code-snippets',
        'core_settings_code_snippets_markup'
    );

enter image description here



Answered By - disinfor
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing