I am looking for insert a Magento 2 block into my theme and would like to load block by id and print the content from block file.
You can use class – “Magento\Cms\Model\Block” to load Magento 2 block by id . Here is the example
$ob = \Magento\Framework\App\ObjectManager::getInstance(); $block = $ob->create('Magento\Cms\Model\Block'); $block->load('block-id', 'identifier'); echo $block->getContent();
0 0 votes
Article Rating