Get CMS Page Collection in Magento 2

You can get all the CMS page collection in Magento 2 by calling interface, Magento\Cms\Api\PageRepositoryInterface.

PageRepositoryInterface is used when you need to fetch a collection of CMS page or get specific CMS page data.

You need to instantiate Interface in __construct() method of Class.

I will give you a demo using Block Class,

From Template file, You need to call a function from Block,

Based on above Code snippet you get all the pages from a website. You can also get specific pages based on your custom condition.

One Reply to “Get CMS Page Collection in Magento 2”

Leave a Reply

Your email address will not be published. Required fields are marked *