WordPress has become one of the most popular blogging platforms. They celebrated their 15th anniversary. This platform can be used by any individual or a website design and development company and In D Amies Technologies we have completed several project in WordPress successfully.WordPress is currently being used in more than 25% of all websites. The reason is that it provides good technical support and most importantly customization. WordPress is loved by people because they aren’t limited to the pre-installed designs. They are free to modify their blog with all the tools provided by WordPress.
Themes and Templates are the backbones of the WordPress customization. But people often get confused between these two. Themes are used to control the way your website looks. It allows us to modify the whole website. Templates are actually a part of Themes. They can be used to change layout and looks of a single page. This is why they are also called Page Templates.
We are here to learn how we can create our own WordPress template. So, let’s see that:
Step 1: Select the part which you want to customize
Templates can be used to modify various parts of the page. Header and Footer are loaded when the page first opens. But it isn’t limited to just these two areas. Using template we can modify header, footer, sidebar, comments etc. Before start building your template, decide which part should be customized or recreated.
Step 2: Create your first template
It’s time to get on real work. Open any text editor and write this code
<?php /* Template Name: Template1 */ ?>
Here we gave a unique name to our template. WordPress will now recognize Template1 as a template. You can name anything you want which relates to the page content. After it is done, save it as Template1.php. Make sure that it should be saved with a .php extension.
Notice that this is template does not contain any code, because it is a sample template to test if it is working or not.
Step 3: Find your theme
Templates are a subpart of themes. So, we have to build our template inside our WordPress theme. Check the current theme name of the website inside the admin panel. Go to /wp-content/themes, find your theme name inside that folder and upload your template file in it.
Step 4: Test the template
Our sample template is ready and successfully uploaded. Now we have to check if it works. Login to your WordPress admin panel and create a new page. You can add a new page inside the Pages section. A page editor will open with several tools to edit it. Go to the ‘Page Attributes’ section and click the drop-down under Template. You will now see two options one is ‘Default Template’ and the second one is ‘Template1’ which we created earlier.
Select the ‘Template1’ to test it. Open the newly created page; you will see not anything as we didn’t do any coding inside the template. It is a common practice to create a sample before doing anything. Even a web development services company would do that to see if anything goes wrong.
Step 5: Editing your Custom Page Template
Editing your custom page template isn’t hard. To modify your template easily you can just copy the contents of current theme and work on it. Find ‘page.php’ file inside your theme’s folder. Copy the whole code and paste it inside your template file except the header.
You will now see the whole code for the various parts of your page. For example, <?php get_sidebar(); ?> is a for sidebar, remove it to get rid of sidebar on your page.
You can also add your custom content instead of editing.