Create a custom page template in wordpress

we have a sidebar on all of pages in wordpress website, but we want to have a page that doesn’t have a sidebar. Here is how we create a custom page template without a sidebar in wordpress:

1)   Create a new file in wordpress theme folder and name it withoutSidebar.php.

2)   Open page.php and copy all of the code and paste it into the newly created withoutSidebar.php.

3)   Make any changes that you would like to withoutSidebar.php. In this example we are going to remove the sidebar, so find the code that calls the sidebar (<?php include(‘sidebar.php’); ?>) and remove it.

4)   You may also want to find the div that contains the main container and add a width style to make it cover the whole page.

5)   Finally, and most importantly, add the following line of code to the top of the page. This code is used to tell WordPress that this is a custom template. Without this code, WordPress would not be able to find the template:

   Template Name: without Sidebar

6)     Save this file and upload it to your server.


Post a Comment