In this tutorial, you will go through how to easily remove block programmatically in magento 2. This trick will be very useful and handy when you want to remove block programmatically with magento 2.
You can simply use
unsetElement() method to remove block. as like
$layout = $this->getLayout(); $block = $layout->getBlock('catalog.topnav'); // block name $layout->unsetElement('catalog.topnav');
I hope you like this post, Please feel free to comment below, your suggestion and problems!