Hello Developers, Greetings of the day!
Sometimes we are not able to access the FTP or cpanel of website but we can access to wordpress admin. At that time using the below line of code you can create a new PHP file or page template in theme directory without use of any wordpress plugging.
Please follow the below steps for create a new PHP file : –
1. First Go to the the theme editor by clicking “Appearance > Theme Editor” in wordpress dashboard.
2. Find the header.php file and click edit.
3. Insert the below code on the very first line of the header.php file. Be sure to change your theme and file name.
<?php touch('wp-content/themes/your_theme_directory/about.php'); ?>
4. Refresh any page of your website in the browser. This will execute the php touch action and create the the new blank PHP file.
5. Now Go to your Theme Editor and you will now see the new PHP file in your theme directory .
If you have create a new template file in theme directory then edit the above about.php file in theme editor and add below line of code in that file.
<?php /* Template Name: About Page */ ?>
Save and enjoy your new page template!
Hope you will enjoy this blog.
Happy coding 🙂