Deseja criar um menu de administração personalizado com dois submenus? Os menus de administração são úteis para sites de associação quando há vários usuários se inscrevendo em seu site. Criamos um trecho de código rápido que você pode usar para criar um painel de administração personalizado add_menu_page
e add_submenu_page
no WordPress.
Instruções:
Tudo o que você precisa fazer é adicionar esse código ao arquivo functions.php do seu tema ou em um plug-in específico do site:
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>'; }
Observação: Se esta é a primeira vez que você adiciona trechos de código no WordPress, consulte nosso guia sobre como adicionar corretamente trechos de código no WordPress para não danificar acidentalmente seu site.
Se você gostou desse snippet de código, considere dar uma olhada em nossos outros artigos no site, como: 25 melhores plug-ins do WooCommerce para aumentar suas vendas rapidamente e como criar um formulário de solicitação de emprego no WordPress.
thanks its work !
very simple and clear, thanks
Thanks! God Bless You
worked! Thanks!
respect!Thankyou!
Thank you sir!
Millions of thanks
+1, translate to Spanish and refered you
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
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
Glad to see you found us 🙂 make sure you bookmark wpsnipp we have more than just
add_menu_page and add_submenu_page… Enjoy!
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
Nice man! Simple and direct, 2 hours searching this solution in google and nothing lol
You is the dude haha
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
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.
Ok thankyou, I’ll try the foother thing.
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
Thanks
Thanks very much m searching this code from the one day. thanx alot…..
its working well thanks
thanks very much its working….
Thanks, it helped a lot!
Cool glad to hear it!