How to add a section at WordPress admin dashboard
When we install a new fresh wordpress and login to its admin panel, we are several options about the wordpress. Also when we start working further and adding few plugins to add more functionality to the website. After sometime we have observed that few new sections explaining the plugins stats adds up to our dashboard. These sections or we can say widgets are added by plugins to show their information at the dashboard.
In the same manner, we can also show our important information at the dashboard which we want to highlight. We can add our custom widgets and able to show that on wordpress dashboard. Below is a example widget code :
function wptricks24_widget_content() { // Put all the details in between echo quotes echo "<ul> <li>Owner Name: Sunil Chaudhary</li> <li>Website: http://www.wptricks24.com/</li> <li>Profession: Front-End/Wordpress Developer.</li> <li>Interests: Playing Volley ball, cricket and TT</li> </ul>"; } function wptricks24_add_dashboard_widgets() { wp_add_dashboard_widget('owner_dashboard_widget', 'Owner Information', 'wptricks24_widget_content'); } add_action('wp_dashboard_setup', 'wptricks24_add_dashboard_widgets' );
Add this code to your functions.php file of your current theme. After adding this code, just login to your wordpress admin and go to dashboard, your widget will show there just like the below image.
Now, above is only a example widget which is just showing the information of the Owner of this blog. You can customize this information easily, you are able to add your information in that section. Above code is just using the wordpress dashboard API.
How To move this section or widget to the top:
The widget create by the above code will show at the bottom of the admin dashboard and we want to show it at the top of our dashboard. It is quite simple, just pick the widget with your mouse pointer, drag to your desired place and then drop it.
Now you are able to add your new widget at your desired place in wordpress dashboard. This widget code support full customization, just put your details inside the function “wptricks24_widget_content” between the echo quotes. This will show your content easily.
Use your wordpress in your way 🙂
Leave a Reply