How to Create a New Template in WordPress?

Photo of author

By Tarun Gawer

Create a new template in WordPress. And if you want to learn how? Follow us in this post. WordPress uses a page.php file for handling formatted output look of all Posts and Pages. But we cannot edit that directly, because that is the way of changing all the default Layouts of the appearance of the website. That is also not considered safe if you use CMS and do not know much about coding languages (HTML, CSS, PHP, Etc..).

How do I Create a new template in WordPress

To Create a new template in WordPress, Please follow the given steps. Here we have taken an example of a Page template without sidebar. So, follow these steps:

  1. Open any Text Editor, like, NotePad.
  2. Type there, as it is
    <?php /* Template Name: NewTemplate */ ?>
  3. Save the file with any name of your choice with .php extension. Eg: NewTemplate.php
  4. Navigate to /wp-content/themes folder and open your current theme and Upload your file(NewTemplate.php) there.

After doing this only if you go to WordPress Admin Panel > Pages > Add New. And see on the right side you will see a new custom template in the list of Templates. But That will not work because we have not yet defined any instructions for that template in our file. For that, you have to enter template codings in the file from anywhere.  But if you want a little bit changes like removing sidebar, increasing content area then follow these steps:

  1. Go to /wp-content/themes/YOUR THEME/ and open page.php.
  2. Copy all the code from there.
  3. Paste the copied code to your custom template file(NewTemplate.php) that you created, but below that line that we wrote for the first time before uploading. And Save.
  4. Now, if you use this Newly created template, then it will work same a default. So to make it a template without the sidebar, find and remove this piece of code:
    <?php get_sidebar(); ?>

    and find and update this:

    <div id="primary" class="content-area">

    with:

    <div id="primary" class="site-content-fullwidth">
  5. And That’s it You new Template without the Sidebar is ready for use.

Here, we have learned how to create a new template in WordPress? If you have any query then comment us now, we will surely reply back to you.

Also Visit: https://justbaazaar.com/css-and-wordpress-customize-your-wordpress-website-with-css/

Discover more from JustBaazaar

Subscribe now to keep reading and get access to the full archive.

Continue reading