How to make a WordPress widget?

In this tutorial I’m showing how to create a WordPress widget. Widget we will create allows you to add to the sidebar a list of products from chosen category. It works with Woocommerce – e-commerce WordPress plugin.

Good practice is to make your WordPress widget as a plugin. So you have to create widget-name.php file under wp-content/plugins directory and at the beginning of it add specific comment text. This text is required by WordPress to show your plugin in Plugins tab in admin panel.