Many people donâ€™t realize that you can heavily customize how WordPress displays your pages. As an example of this, letâ€™s pretend that you need a page on your site to not display the sidebar (like if you needed to display a large picture or calendar).
There are 3 steps to remove the WordPress Sidebar:
- Create a new Page Template
- Remove the Sidebar Code
- Apply Page Template
Below I will break down the steps and show you exactly how to make a custom page template that does not display the sidebar.
How to Create a Custom WordPress Template cats zithromax in
This process actually isnâ€™t that difficult. Log into your FTP server and navigate your way to your Themeâ€™s template files. Locate the file called â€œpage.phpâ€ and duplicate it. Then rename the copied file something easy to remember such as â€œcustom template oneâ€ or something. The name is not important, you just have to remember which one does what.
The custom file is now created. So the next thing we have to do is make a couple changes for it to be different from a regular WordPress page.
Arthur et les Minimoys psp Removing the WordPress Sidebar
Now open the file in your editor of choice (I prefer TextEdit on my Mac). First, you need to name the template for WordPress to read. Add the following code to the top of your new template file:
<!—display code><?php /* Template Name: New Name of template here */ ?><–!>
If copy and pasting it does not work here, it may be easier for you to find this code in a existing template on your own blog. Just change the name of the template and it should work just fine.
Once youâ€™ve done that, itâ€™s time to remove the line of code that calls and displays the sidebar when the page is generated. Look towards the end of the template file for the following line of code (it may be slightly different in your theme, just look for anything with â€™sidebarâ€™ in it):
<!—display code><? php get_sidebar(); ?><—!>
Delete that line of code and save the file. Then you must upload it back to your theme directory on your server. The template will no longer pull up the sidebar when a page is displayed using this template.
Turning on Your Custom WordPress Page Template prednisone tapering schedule
Now that your new page template is on the server, you have to edit the page you want to apply the template to in the WP-Admin. In the page edit window, look for the â€œAttributesâ€ section. Youâ€™ll see an option to select a different template. If you followed all the steps, the name you wrote in step two should appear on the list. Select it, save the page. The page is now setup to utilize the custom page template you created.
Go to the page on the live site and make sure the sidebar isnâ€™t there. Now that you know how to customize a page template, you can learn the PHP codes that WordPress uses and develop your own template pages.
Other Uses For Custom Page Templates
Displaying a page without the sidebar is only the beginning of custom page templates in WordPress. You can create templates for category pages, single posts, and archives to name a few. I have utilized page templates for posts to display different sidebars depending on the category of the post. This makes it very simple to display different advertisements based on the category of your post.
Page templates have unlimited flexibility and can take your WordPress blog or website to the next level. Just make sure to back everything up because mistakes can sometimes happen when editing the theme files.
Do you have any clever uses for a custom WordPress page template?