Follow these steps to create a new widget and add it to the Widgets section:
- Open the wp-content/themes/twentytwentychild folder of your WordPress installation and open the functions.php file.
- Add the following code at the end to define the basic structure of a widget:
class WP_Widget_Product_Pages extends WP_Widget { public function __construct() { $widget_ops = array( 'classname' => 'widget_product_pages', 'description' => __( 'Pages with Product Landing Page Template.' ), ); parent::__construct( 'product-pages', __( 'Product Pages' ), $widget_ops ); } public function form( $instance ) { // Code in Step 3 should be added in the next line } public function widget( $args, $instance ) { // Code in Step 4 should be added ...