magento 2 how to add magestore slider in blog phtml file
-
21-03-2021 - |
Question
Here I have a blog page there I wanted to display banner sliders. I configured the sliders they working fine in home page, but am unable to add in custom phtml(blog) page here is my blog Phtml file
<?php
$this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();
$blockObj= $block->getLayout()->createBlock('Mageplaza\Blog\Block\Listpost');
$blockImageResize= $block->getLayout()->createBlock('Mageplaza\Blog\Block\Frontend');
// $coll = $blockObj->getPostCollection();
?>
<div>
<?php
?>
</div>
<div class="mp-blog-rss">
<a href="<?= $block->getRssUrl('post/rss') ?>" class="bb-rss-icon">
<img src="<?= $this->getViewFileUrl('Mageplaza_Blog::media/images/rss.png') ?>" width="16px">
</a>
</div>
What am doing wrong? can i get help? Thank you.
Solution
Please! Change your code
From
$this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();
To
echo $this->getLayout()->createBlock("Magestore\Bannerslider\Block\SliderItem")->setSliderId(3)->toHtml();
Hope this will help you!!
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange