How To Get Magento 2 Block Content By Id

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
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments