I want to make a menu button that takes me to wp-admin/widgets.php. The above code seems to work only partially.

add_action( 'admin_menu', 'register_widgets_menu_button' );

function register_widgets_menu_button(){
  add_menu_page( 'Widgets', 'Widgets', 'manage_options', 'widgets', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ), 6 );

function my_custom_menu_page(){
  include ( 'widgets.php' );

I get to the widgets page, but in a peculiar way. Here is the URL that I see in the address bar:


But there is a PHP error breaking the page (I can't see all the widgets). Here is the error:

Notice: Undefined variable: wp_registered_sidebars in htdocs/wp-admin/widgets.php on line 403

You can add a link to the widgets.php like that:

add_action( 'admin_menu', 'f711_add_widgets_shortcut', 999 );

function f711_add_widgets_shortcut() {

    add_menu_page( 'Widgets', 'Widgets', 'publish_pages', 'widgets.php', '', '', 61 );


Be sure to check your permission settings, and you may also include another image. You can find the documentation about the function at The Codex.

  • Perfect! Thanks, this is exactly what I was looking for! – Moose Jan 21 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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