---
title: "Magento 2: How to Add Custom Button in Backend CMS Page Section"
url: "https://magecomp.com/blog/magento-2-add-custom-button-in-backend-cms-page/"
date: "2023-07-21T11:16:00+00:00"
modified: "2025-02-13T04:44:07+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 613
reading_time: "4 min read"
summary: "Hello Magento Friends,"
description: "Magento 2 allows you to create various customizations tailored to your specific needs. Learn How to Add Custom Button in Backend CMS Page Section."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Create Country &amp; State Dropdown in Magento 2 Custom Frontend Form?"
    url: "https://magecomp.com/blog/create-country-state-dropdown-in-magento-2-custom-frontend-form/"
  - title: "The Top-Rated Facebook Shop Integration Extension with Magento 2"
    url: "https://magecomp.com/blog/best-facebook-shop-integration-extension-for-magento-2/"
  - title: "How to Create Credit Memo Programmatically Using Root Script in Magento 2?"
    url: "https://magecomp.com/blog/create-credit-memo-programmatically-using-root-script-magento-2/"
---

# Magento 2: How to Add Custom Button in Backend CMS Page Section

_Published: July 21, 2023_  
_Author: Dhiren Vasoya_  

![How to Add Custom Button in Backend CMS Page Section in M2](https://magecomp.com/blog/wp-content/uploads/2023/07/How-to-Add-Custom-Button-in-Backend-CMS-Page-Section-in-M2-1024x512.webp)

**Hello Magento Friends,**

I am back with yet another useful Magento solution. Today it’s about Adding a Custom Button in the Backend CMS Page Section of your Magento 2 admin.
[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-2.webp)](https://magecomp.com/magento-malware-removal.html)

As a Magento 2 store owner or developer, you might encounter situations where you need to enhance the backend CMS Page section with custom functionalities. One common requirement is adding a custom button to perform specific actions related to CMS pages.
This capability empowers you to extend the functionality of your Magento store and streamline content management processes. With the custom button in place, you can perform specific actions related to CMS pages directly from the backend, providing a more efficient and user-friendly experience for content managers and administrators.
Let’s look at the step-by-step process to Add a Custom Button in Magento 2 Backend CMS Page Section.
## Steps to Add Custom Button in Magento 2 Backend CMS Page Section:
**Step 1:** First, we need to create a **cms_page_form.xml** file inside the extension at the following path.
**app\code\Vendor\Extension\view\adminhtml\ui_component**

Then add the code as below.
```
<?xml version="1.0" encoding="UTF-8"?>
 <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
  <fieldset name="search_engine_optimisation" sortOrder="20">
         <field name="meta_title" formElement="input" sortOrder="21">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">page</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <label translate="true">Meta Title</label>
                <dataScope>meta_title</dataScope>
            </settings>
        </field>
            <container name="cms_meta_title_button_container" sortOrder="22">
            <htmlContent name="html_content">
                <argument name="block" xsi:type="object">VendorExtensionBlockAdminhtmlCmsEditCmsbutton</argument>
            </htmlContent>
        </container>
   </fieldset>
</form>
```

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

**Step 2:** After that, we need to create a **Cmsbutton.php** file inside the extension at the following path.
**app\code\Vendor\Extension\Block\Adminhtml\Cms\Edit**

And add the following code snippet.
```
<?php
namespace VendorExtensionBlockAdminhtmlCmsEdit;

class Cmsbutton extends MagentoBackendBlockTemplate
{
    protected $_template = 'Vendor_Extension::cms/button.phtml';

    public function __construct(
        MagentoBackendBlockTemplateContext $context,
        array $data = []
    ) {
        parent::__construct($context, $data);
    }
    public function getButtonHtml()
    {
        $button = $this->getLayout()->createBlock('MagentoBackendBlockWidgetButton')->setData(['id' => 'custom_button', 'label' => __('Button Label'),'class'=>'action- scalable save primary']);
        return $button->toHtml();
    }
}
```

**Step 3:** After that, we need to create a **button.phtml** file inside the extension at the following path.
**app\code\Vendor\Extension\view\adminhtml\templates\cms**

Finally, append the below piece of code.
```
            <?php
            echo $block->getButtonHtml();
        ?>
    ```

**Output**

Now, you should see the custom button in the backend CMS Page edit section, and when clicked, it will trigger the action defined in the controller.
![custom button in cms page](https://magecomp.com/blog/wp-content/uploads/2023/07/custom-button-in-cms-page.png)

## Conclusion:
By following the steps outlined in this article, you can easily add a custom button to the Magento 2 backend CMS Page section. Other areas to add a custom button on the backend admin
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-2.webp)](https://magecomp.com/services/hyva-theme-development/)

- [**Add Custom Button on Admin Sales Order View Page in Magento 2**](https://magecomp.com/blog/add-custom-button-admin-sales-order-view-page-magento-2/)
- [**Add Custom Button in Backend Category Page Section in Magento 2**](https://magecomp.com/blog/magento-2-add-custom-button-in-backend-category-page/)

Share the article with your friends and stay in touch with us.
**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-custom-button-in-backend-cms-page/](https://magecomp.com/blog/magento-2-add-custom-button-in-backend-cms-page/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-20 08:38:26 UTC_  
