I have added widget(call static block) in category description http://prntscr.com/ko816y.
But it is not call widget in front just showing output as it look in admin WYSIWYG editor.
So,I want to convert below code to html

{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="10"}}

enter image description here How can I convert widget code to html?

I have Call Description like this way

<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->categoryAttribute($block->getCurrentCategory(), $_description, 'description') ?>
  • 2
    Can you explain how can call description for the category? Sep 3, 2018 at 9:03
  • 1
    may I know Magento 2 version?
    – kunj
    Sep 3, 2018 at 9:24
  • It's 2.2.2 version I have update my Question Sep 5, 2018 at 6:23
  • @KetanBorada Any solution for convert widget code to html? Jun 30, 2022 at 13:00
  • @JitendraPatel use solution from Taschert Sep 17, 2022 at 6:01

2 Answers 2


you need to pass the content of the description inside a function before the display. This filterProvider will replace the widget code inside the content of the description.

public function __construct(
    \Magento\Cms\Model\Template\FilterProvider $filterProvider
    $this->_filterProvider = $filterProvider;

public function addWidget($description) {
     $newDescription = $this->_filterProvider->getPageFilter()->filter(
     return $newDescription;

I don't know why it doesn't work for you, basically {{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="10"}} should work in cms page, category descriptions etc...

I have some workaround, it is not very best way but try it:

  1. Create phtml in : app/design/frontend/{Vendor}/{theme}/Magento_Theme/templates/html/category-description.phtml

    <?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId("static-block-indentifier")->toHtml(); ?>
  2. In your category description area >Wysiwyg editor > show/hide editor > add this:

    {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/category-description.phtml"}}

Now you should get your static-block content in your category description.

  • please check my question again i called widget for call static block you have put it directly.non technocal user can not call static block directly as you have did Sep 10, 2018 at 6:54
  • I didn't understand your comment, non technocal user can not call static block directly ? Why I can't call a static-block directly ? you mean this <?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId("static-block-indentifier")->toHtml(); ?> whats wrong here ?
    – PЯINCƎ
    Sep 10, 2018 at 7:56
  • I want to decode widget in category description you have call static block by fix Identifier.It is not neceessary to call only static block from widget there are many functionality within widget. prntscr.com/ksmilu it is not only for static block Sep 10, 2018 at 9:24
  • I want to decode all these things in front-end prntscr.com/ksmjqd . prnt.sc/ko816y Sep 10, 2018 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.