0

I'm trying to do one custom menu at my wordpress admin panel.

My plans are: make and menu, to add some contents at a custom page, like "people" and their names, etc...

I wanna make it with php.

I used this only to view whats happen:

add_action('admin_menu', 'register_my_custom_submenu_page');

function register_my_custom_submenu_page() {
    add_submenu_page( 'tools.php', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' ); 
}

function my_custom_submenu_page_callback() {
    echo '<h3>My Custom Submenu Page</h3>';

}

It added an page, inside tools menu, what can I do to create on an exclusive menu??

On my_custom_submenu_page_callback, what can I do to work with embedded PHP code? like mysql_query and stuff?

4
  • 1) What does "create on an exclusive menu" mean? 2) "what can i do to work with embbed php code"? -- You know how PHP works, right? From another perspective, you already have "embedded" PHP on the page so what is the question?
    – s_ha_dum
    Commented Aug 20, 2013 at 1:52
  • @s_ha_dum exclusive menu i mean like this: -Photos --Add Photos Inserting like, mysql_query("blablabla") at submenu callback it will works?
    – PlayMa256
    Commented Aug 20, 2013 at 1:55
  • That doesn't tell me anything? Do you mean something like "top-level menu"?
    – s_ha_dum
    Commented Aug 20, 2013 at 2:00
  • yeah yeah...i was missing this word..
    – PlayMa256
    Commented Aug 20, 2013 at 2:01

1 Answer 1

0

If I understand you, what you are doing is almost correct. You need add_menu_page instead of add_submenu_page

add_action('admin_menu', 'register_my_custom_submenu_page');

function register_my_custom_submenu_page() {
    add_menu_page( 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' ); 
}

function my_custom_submenu_page_callback() {
    echo '<h3>My Custom Submenu Page</h3>';

}

As far as the "embedded" PHP, you already have it. Everything in that code is PHP. You can add whatever other PHP you want inside that callback (my_custom_submenu_page_callback) and it should work so long as the PHP itself is valid and you watch out for variable scope and such.

Your capability-- manage_options-- may need to be changed. That depends on how you want it to work.

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.