Expert Group of programming
Loading...

How to Remove ‘WP dashboard widget. ‘

Posted by : Heycode Tech | Posted in : admin customization, wordpress, WordPress Functions | Sep 15,2015 | 0 comments

WP Dashboard is a collection of predefined widget. Now you can create the own custom widget which will display on the wordpress dashboard widget.

Here is the wp dashboard area : it will different of the wordpress widget(Appearence -> widget) .

wpdashboard

For removing the widget, we need to call the function : unset : . Here is the example of the code for removing the widget .

Use this code in functions.php file .

 /*
	Disable Default Dashboard Widgets
*/
function heycodetech_dashboard_widgets() {
	
	global $wp_meta_boxes;
	// wp..
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
	// bbpress
	unset($wp_meta_boxes['dashboard']['normal']['core']['bbp-dashboard-right-now']);
	// yoast seo
	unset($wp_meta_boxes['dashboard']['normal']['core']['yoast_db_widget']);
	// gravity forms
	unset($wp_meta_boxes['dashboard']['normal']['core']['rg_forms_dashboard']);
	
}
add_action('wp_dashboard_setup', 'heycodetech_dashboard_widgets', 999);

It will hide the dashboard widget permanently for all the users.

How to create own wp dashboard widget

/*
 * Adding the heycodetech dashboard widget. 
 * 
 */

// Add Dashboard Widgets

function heycodetech_dashboard_widget_function() {

echo "<p>Welcome to <a href='".home_url()."' >".home_url()."</a> Content Management System (CMS):</p>\n"; 

echo "\n";	

} 

function heycodetech_add_dashboard_widgets() {

	wp_add_dashboard_widget('heycodetech_dashboard_widget', 'Welcome To Corporate Law Reporter', 'heycodetech_dashboard_widget_function');	

} 

add_action('wp_dashboard_setup', 'heycodetech_add_dashboard_widgets' );

Here is the above example will use to create the wordpress dashboard widget. Now you can show any information on the dashboard.

For use the hooks :wp_dashboard_setup : This hooks will used to generate the widget as well as remove the widget from wordpress. For more details,please see the above both examples.

For more details, please visit on codex.wordpress.com or write a comment, We will provide all the answer here.

Tags:

Author information - Heycode Tech

Every world can ask question and my website registered user give the suggestion.

See all posts by Author

Connect to author

About us

Heycodetech is a platform where you can ask any questions related to the programming like PHP,jQuery, MYSQL,HTML , CSS and moreHere is the Expert group of programming.