How can I add a custom wordpress widget to show in my admin dashboard?

I have written the code for my wordpress widget using

class BeginnerLinks_Widget extends WP_Widget {

And all that, basically doing it the ‘proper’ way. I added

Read More
function register_BeginnerLinks_Widget() {
register_widget( 'BeginnerLinks_Widget' );
}
add_action( 'widgets_init', 'register_BeginnerLinks_Widget' );

At the end of my php file which is beginnerLinksWidget.php and that is located in my wp-includes folder. But I also placed it in other areas of my htdocs as well.

Having this widget as a stand alone file did not work for me and I could not see it in my dashboard under appearance/widgets. To make it work I added the file in a plugin folder I made before, and added the widget file as a require_once() and then I was able to see it in my dashboard and use it.

Is this the only way to have a widget added to the dashboard? Is there a way to have a standalone widget without the need of a plugin.

Related posts

Leave a Reply