Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 Aug 20 '13 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? –  Matheus Silva Aug 20 '13 at 1:55
    
That doesn't tell me anything? Do you mean something like "top-level menu"? –  s_ha_dum Aug 20 '13 at 2:00
    
yeah yeah...i was missing this word.. –  Matheus Silva Aug 20 '13 at 2:01
add comment

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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