->

How do I get rid of / disable the sidebar in WordPress? Templates, of course.

This was the question I was grappling with yesterday. Since the site is database driven, how do you make one specific page act differently than the rest? I needed the whole width real estate on the church’s blog for a calendar, but I wanted the sidebar on every other page, just not that one.

Well, in most templating systems, you have different templates you apply to different pages. It just seemed to be downplayed when you are considering using Word Press as your CMS.

I happened to stumble across this option when searching for a solution. To assign a page a different template than the default, you look to the drop down menu called “Page Template” under Attributes that has a list of available templates. But how do you add templates to that list?

Page Templates Drop Down Menu

Well, you create a new file in your theme folder, name the file what you want, and include this comment designation at the top, inside PHP tags, so that WordPress parses it and knows that it should be used as a page template. (You may want to use the existing page template as a start);

/*
Template Name: (Name)
*/

Where (Name) is the name you enter that you want to use when choosing it as your option. Works like a charm. You may have to change some of your CSS to make the new page work if you have a sidebar in your other templates, but other than that it’s pretty simple. If you ftp your file to the server and you don’t see the new template in the menu, then check your PHP code formatting, WordPress obviously isn’t seeing it as a template file.

Here are some similar arcade posts

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
User Gravatar

I’m not finding the drop down menu called Page Template that you mentioned in this post. How do I get it to show?

User Gravatar

I have added a screenshot and fleshed out more of the instructions. This will show you were you should see the ‘Page Template’ section. What version of WordPress are you using?

User Gravatar

Thx. Wow – it is completely missing. I’m using 2.9.2. I’ve got Parent and Order but Template is not there. I wonder if the theme is blocking it?

User Gravatar

The drop down won’t show up until you’ve created the file successfully. If the menu isn’t there, WordPress doesn’t recognize it as a page template. Double check your syntax. If you need help, I am available at an hourly rate.

User Gravatar

Thank you! I created a new template called no_sidebar by adding that code to the top of the page.php file, saving it as no_sidebar.php and and voila! Now the template shows up in the drop down. Thanks again.

User Gravatar

Is it possible to choose different templates for posts in different categories?

User Gravatar

There is a plugin for WordPress that allows you to set specific themes on individual posts and pages called ThemePerPost. I haven’t used it extensively, but I assume it could work on categories as well.

Sorry, the comment form is closed at this time.