Magento 2 – How to Call CMS Page in Anchor Tag

cms-pagesmagento2

I am new in magento2. I saw many question but i can't understand flow.

can any one help me how to call cms page in anchor tag ?

I tried some code but it is not working.

<a href="<?php echo $this->getUrl('footer'); ?>">CMS PAGE LINK</a>

Thanks in advance 🙂

Best Answer

You can get url by page ID, Try this flow :-

$pageId = 1;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$cms_page_url = $objectManager->create('Magento\Cms\Helper\Page')
->getPageUrl($pageId);

Add this code in phtml :-

<a href="<php echo $cms_page_url; ?>">CMS PAGE LINK</a>
Related Topic