2.7 (53.19%) 47 votes

There are 5 steps to create a new widget in Magento 2 (Magento 2.3)

  • 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

Your Magento website needs a powerful Magento ERP for stock control.

DON'T MISS THE CHANCE!

magento erp

How to Translate a String by Code in Magento 2 - Magento 2.3
How to add Column Control into Magento 2 Admin Grid by UI Component? - Magento 2.3