I am trying to add a new template in the WordPress site editor like this like this

but unable to do it with my custom plugin.

I have found a filter to register a custom template

add_filter( 'default_template_types', 'register_template_type' );

function register_template_type( $templates ) {
            $templates['help-us'] = array(
                'title'       => _x( 'Page: Help Us', 'Template Name' ),
                'description' => __( 'Displays Help Us template' ),

            return $templates;

after adding this code I have figured out that by adding a file in the theme's template directory help-us.html I was able to register and display my custom template.

enter image description here

My question is how we can do this via plugin? Is there any way we can add a custom template via plugin folder? Like we can do in case of WooCommerce and other plugins. I am unable to find any hook for that.



Syed Ali Ahmed

1 Answer 1


Two of the best ways to do this are (1) by using Create Block Theme plugin or a (2) Child theme. Why complicate it with a new plugin?

In the child theme, create a templates folder, and in that, add a custom-template.html file.

You can also add a new template by using the Plus + button on top to add a new template and export it as either a new theme or as a child theme using Create Block Theme

Create a New Template

  • Maybe the OP wants their plugin's functionality include a template. Like copying the theme's page.php into a template that can be modified to include some functionality added by the plugin. The process to have a plugin register a template is not well-documented. Jul 10, 2023 at 20:48
  • Yes, as suggested by @RickHellewell I want to add this option in my existing plugin, I can not do this via child theme. Jul 11, 2023 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.