X

Crear add_menu_page personalizada con add_submenu_page Panel de administración

Snippets by IsItWP

¿Desea crear un menú de administración personalizado con 2 submenús? Los menús de administración son útiles para los sitios de membresía cuando tiene varios usuarios que se registran en su sitio web. Hemos creado un fragmento de código rápido que puede utilizar para crear add_menu_page personalizado y add_submenu_page panel de administración en WordPress.

Instrucciones:

Todo lo que tienes que hacer es añadir este código al archivo functions.php de tu tema o en un plugin específico del sitio:

 
function theme_options_panel(){
  add_menu_page('Theme page title', 'Theme menu label', 'manage_options', 'theme-options', 'wps_theme_func');
  add_submenu_page( 'theme-options', 'Settings page title', 'Settings menu label', 'manage_options', 'theme-op-settings', 'wps_theme_func_settings');
  add_submenu_page( 'theme-options', 'FAQ page title', 'FAQ menu label', 'manage_options', 'theme-op-faq', 'wps_theme_func_faq');
}
add_action('admin_menu', 'theme_options_panel');

function wps_theme_func(){
		echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
		<h2>Theme</h2></div>';
}
function wps_theme_func_settings(){
		echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
		<h2>Settings</h2></div>';
}
function wps_theme_func_faq(){
		echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
		<h2>FAQ</h2></div>';
}

Nota: Si es la primera vez que añades fragmentos de código en WordPress, consulta nuestra guía sobre cómo añadir correctamente fragmentos de código en WordPress, para no romper accidentalmente tu sitio.

Si le gustó este fragmento de código, por favor considere revisar nuestros otros artículos en el sitio como: 25 mejores plugins de WooCommerce para hacer crecer tus ventas rápidamente y cómo crear un formulario de solicitud de empleo en WordPress.

Comentarios   Deja una respuesta

  1. thanks its work !

  2. very simple and clear, thanks

  3. Jailson Pacagnan Santana abril 27, 2020 en 8:47 pm

    Thanks! God Bless You

  4. worked! Thanks!

  5. respect!Thankyou!

  6. Savanolka Gardouchtra mayo 30, 2019 en 4:39 am

    Thank you sir!

  7. Akhtarujjaman Shuvo marzo 22, 2019 en 2:58 pm

    Millions of thanks

  8. Luis Miguel Devloper junio 16, 2015 en 4:51 pm

    +1, translate to Spanish and refered you

  9. Excellent, very good. Thanks for you help. I have a question, how can visuality this menu at the rol “invitador” ? for example:

    $result = add_role( ‘invitador’, __(‘Invitador’ ),array(

    ‘theme_options_panel’ => true,

    )); ??

    Thanks my friend

  10. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

    1. Glad to see you found us 🙂 make sure you bookmark wpsnipp we have more than just

      add_menu_page and add_submenu_page… Enjoy!

  11. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

  12. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

  13. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

  14. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

  15. grupobrasilonline mayo 2, 2014 en 4:58 am

    Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol

    You is the dude haha

  16. Is it posible to add a top level item with current user info (avatar, username, first and last name, something like the top right user info pannel in the admin bar. I want to do this because i didnt find any solution for front end posting that fits all my needs so Ill let user post fron the backoffice but I want to make a really cool experience by adding some cool stuff in the admin area. Heres and example https://dl.dropboxusercontent.com/u/12646264/example-user-info-pannel.jpg

    1. Hi Aeonx,

      I don’t think so as add_menu_page would only except specific parameters. The only thing I could think of would be to try and add HTML within the title. The problem is that would be placed within an anchor. The other option would be to insert something into the footer of the admin then use javascript to remove and place it into the admin menu after the fact. Keep in mind this is not something I have looked into so may be an easier way.

      1. Alberto Hartzet marzo 12, 2014 en 10:00 am

        Ok thankyou, I’ll try the foother thing.

  17. Is it posible to add a top level item with current user info (avatar, username, first and last name, something like the top right user info pannel in the admin bar. I want to do this because i didnt find any solution for front end posting that fits all my needs so Ill let user post fron the backoffice but I want to make a really cool experience by adding some cool stuff in the admin area. Heres and example https://dl.dropboxusercontent.com/u/12646264/example-user-info-pannel.jpg

  18. Thanks

  19. Thanks very much m searching this code from the one day. thanx alot…..

  20. its working well thanks

  21. thanks very much its working….

  22. Thanks, it helped a lot!

    1. Cool glad to hear it!

Añadir un comentario

Nos alegra que haya decidido dejar un comentario. Tenga en cuenta que todos los comentarios se moderan de acuerdo con nuestra política de privacidad , y que todos los enlaces son nofollow. NO utilice palabras clave en el campo del nombre. Tengamos una conversación personal y significativa.

WordPress Launch Checklist

La lista definitiva para lanzar WordPress

Hemos recopilado todos los elementos esenciales de la lista de comprobación para el lanzamiento de su próximo sitio web de WordPress en un práctico ebook.
Sí, envíeme el ¡gratuito!