There are 5 steps to create a new widget in magento 2

  • Step 1: Initialize widget
  • Step 2: Create a widget template
  • Step 3: Create a widget block
  • Step 4: Flush Cache
  • Step 5: Post Widget

Step 1: Initialize widget

File directory: app/code/Magestore/HelloMagento/etc/widget.xml

Step 2: Create a widget template

File directory: app/code/Magestore/HelloMagento/view/frontend/templates/widget/posts.phtml

Step 3: Create a widget block

File directory: app/code/Magestore/HelloMagento/Block/Widget/Posts.php

Step 4: Flush Cache

Open terminal and use this command:

Php bin/magento cache:flush

Step 5: Post widget

Go to admin panel > Content > Pages > Home page > Edit

In Content tab, click on Insert Widget icon. You will see the New Widget in widget list

Create Widget in Magento 2

Create Widget in Magento 2
Create Widget in Magento 2

We also contribute great content of Magento Tutorial for Magento 1.x.

DON'T MISS THE CHANCE!

magento tutorial

How to Run Enable/Disable Maintenance Mode in Magento 2
How to use Memcache in Magento 2 in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *