I'm interested in adding a widget area to the top of the Dashboard page at site URL /wp-admin to display some important notes for the editors/developers of the site.

How would I go about this?


1 Answer 1


Let's dig into dashboard's internals to see what we can do. https://core.trac.wordpress.org/browser/tags/5.3/src/wp-admin/_index.php#L129

First it renders welcome_panel via do_action( 'welcome_panel' ); so you can hook to it and output your custom content on top over all other widgets.

You can also remove_action('welcome_panel') before attaching your own to remove default or other content from being rendered there, and to render only your own one.

And this is essentially answer to your question. -> you create custom function which will echo your html, that you'd like to be displayed together with or instead of welcome_panel and hook it via add_action( 'welcome_panel', 'your_custom_top_widget_renderer' );

Default welcome panel is attached via add_action( 'welcome_panel', 'wp_welcome_panel' );

You can checkout wp_welcome_panel function which is used to render welcome panel in WP by default here https://core.trac.wordpress.org/browser/tags/5.3/src/wp-admin/includes/dashboard.php#L1757 To get a css classes\markup and functionality inspiration for your custom welcome panel renderer.

BUT this isn't a placeholder for dashboard widgets, so essentially you can render there whatever you wish, but out of the box features like drag and drop to reorder or place there some other widgets via drag and drop will not work.

And let's speak about Dashboard widgets.

Looking a bit down below https://core.trac.wordpress.org/browser/tags/5.3/src/wp-admin/_index.php#L148

shows us wp_dashboard() function call which is used to render dashboard widgets and their placeholders, so all out of the box drag and drop reorder and other functionality of real dashboard widgets works. https://core.trac.wordpress.org/browser/tags/5.3/src/wp-admin/includes/dashboard.php#L230

This function renders widgets and 4 placeholders for widgets and they are in 2 columns UI. So without rewriting this function it's not possible to inject some 5th placeholder or something like that.

UPD: I came up with crazy idea but you can give it a try. you can fire <?php do_meta_boxes( $screen->id, 'top_welcome_custom', '' ); ?> inside your custom welcome_panel action function and you'll have metaboxes list rendered there as well. This will require to do JS tricks to make them sortable etc. but who said that it would be straight if we do something really custom.

I hope at least from your explanation that you are going just to display some information there. So no real need for metaboxes.

  • Thanks very much for putting that information together! I'll work my way through it, and see what I can do. Apr 6, 2020 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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