WordPress

WordPress TutorialRemove Version from WordPress and StylesheetsRun WordPress local with XAMPPSecurity in WordPress - EscapingSecurity in WordPress - SanitizationThe Loop (main WordPress loop)Update WordPress ManuallyWordPress Actions and FiltersWordPress add action()WordPress add editor style()WordPress add menu page()WordPress Add ShortcodeWordPress add submenu page()WordPress add theme support()WordPress Add/remove contact info for users with user contactmethods filter hookWordPress Admin Dashboard WidgetsWordPress AJAXWordPress Alternating main loop (pre get posts filter)WordPress Child Theme BasicsWordPress Create a Post ProgrammaticallyWordPress Create Template for Custom Post TypeWordPress Creating a custom templateWordPress Custom exerpts with excerpt length and excerpt moreWordPress Custom Post TypesWordPress Customizer Basics (Add Panel, Section, Setting, Control)WordPress Customizer Hello WorldWordPress DebuggingWordPress Enqueuing scriptsWordPress Enqueuing StylesWordPress Function : wp trim words()WordPress Function: add action()WordPress get bloginfo()WordPress get home path()WordPress get option()WordPress get permalink()WordPress get template part()WordPress get the category()WordPress get the title()WordPress home url()WordPress How Can I integrate Markdown editor with Advance Custom Fields repeater Add-on.WordPress initWordPress Installation and ConfigurationWordPress Making network requests with HTTP APIWordPress Meta BoxWordPress Options APIWordPress Plugin creationWordPress Plugin developmentWordPress Post FormatsWordPress Querying postsWordPress Remove Auto Line Breaks from Content and ExcerptWordPress REST APIWordPress Secure your installationWordPress ShortcodeWordPress Shortcode with attributeWordPress ShortcodesWordPress SidebarsWordPress Site MigrationWordPress TaxonomiesWordPress Template hierarchyWordPress template includeWordPress the $wpdb ObjectWordPress the Admin Bar (aka The Toolbar)WordPress the title()WordPress theme and child-theme developmentWordPress ThemesWordPress wp get current user()WordPress WP Query() LoopWordPress WP-CLIWordPress WP-Cron



WordPress Admin Dashboard Widgets

From WikiOD

With an admin dashboard widget you are able to display any kind of information at the admin dashboard. You can make multiple widgets if you want. You can add the code to the functions.php of your theme or to your plugin.

Syntax[edit | edit source]

  • add_action($tag, $function_to_add, $priority, $accepted_args);
  • wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback, $callback_args);

Parameters[edit | edit source]

Parameter Details
$tag (string required) Name of the action where $function_to_add is hooked
$function_to_add (callable required) Name of the function you want to call.
$priority (int optional) Place of the function call in all functions of action (default = 10)
$accepted_args (int optional) Number of parameters the function accepts (default = 1)
$widget_id (string required) Unique slug for your widget
$widget_name (string required) Name of your widget (displayed in the head)
$callback (callable required) Name of the function which displays die content of your widget
$control_callback (callable optional) Name of the function which handles the widget options forms
$callback_args (array optional) Parameters of the $control_callback function

Simple widget (displays text)[edit | edit source]

This will add a simple widget which displays just a small message.

 add_action('wp_dashboard_setup', 'register_my_dashboard_widgets');

 function register_my_dashboard_widgets() {
     wp_add_dashboard_widget('myInfo_widget', 'Important Information', 'display_infoWidget');
 }

function display_infoWidget() {
     echo '<p>At the first of february this site gets a new design.
     Therefore is wont be available this day. To see the current progress you can visit 
     <a href="http://www.justanexample.com" >this site</a></p>';
 }

This article is an extract of the original Stack Overflow Documentation created by contributors and released under CC BY-SA 3.0. This website is not affiliated with Stack Overflow