Reusing the slider as a widget

We had a brief introduction to widgets and their role in WordPress. Widgets was intended to add blocks of features to the sidebar of the site. However, with modern themes and widget areas, widgets can be considered as a reusable block of features similar to shortcodes. So, we are going to look at the process of building a frontend widget in WordPress. Let's start by adding a new file to the classes directory of our plugin with a class called WQKM_Product_Slider_Widget.

In this scenario, we will be building a widget to display the product slider created in the previous section. So, we can reuse the shortcode functionality for this widget. Let's take a look at the implementation of the widget, using the following ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.