How to change the name of default template for pages in WordPress
When we are adding a wordpress page, we can select the page attributes from the right side of the screen. Page attribute includes template selection as we know that we can select the template of our choice from the dropdown.
We can create our own template for any specific page. In the same manner we are able to create a generalized template for multiple pages. To create a template we just need to write the template name in commented format. Our custom templates will appear in wordpress page edit screen in template dropdown under attributes section. We can choose template of our choice for particular page from the dropdown.
Now you can see there is a “Default Template” always appears in the dropdown and it comes selected for every new page by default. It is a wordpress default template for all pages and we can modify its appearance and features from the page.php file of our current theme. When we are creating our website and we want the name “Default Template” should matches to our website name like “Mywebsite Template” or anything else we want then we can change it by using a predefined wordpress hook that is “default_page_template_title”.
To change this for your website, just copy the below mentioned code and paste it in functions.php file of your current theme :
function wptricks24_change_template_name( $label, $context ) { return __( 'Wptricks24 Default Template', 'textdomain' ); // new template name will be "Wptricks24 Default Template" } add_filter( 'default_page_template_title', 'wptricks24_change_template_name');
Just look at the above code, “Wptricks24 Default Template” is the name for my website default template. You can modify it as per your website name or anything which you want to show for a default template in wordpress pages in admin area.
In the above code we are using a default filter hook of wordpress that is “default_page_template_title”. This hook was first introduced in wordpress version 4.1 so you can use this code for all wordress version after that.
This code will not affect any other functionality of your website, it will only change the name of default template silently. 🙂
Leave a Reply