Make a WordPress template page with no sidebar

by mitz on June 19, 2010

Here is a quick video tutorial on how to make a new page template for your WordPress Website. This is kind of advanced stuff so if this is your first time in making a page template, please practice on a test blog or something that is not too valuable. This template code will not work with all WordPress themes, however I have used it on more than 10.. You might have to change the code a bit to get it to work…

Here is the PHP code that I used to make this page template:

<?php
/*
Template Name: Nosidebar
*/
?>
<?php get_header(); ?>

<div id=”content”>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div id=”post-<?php the_ID(); ?>”>
<div>
<h1><?php the_title(); ?></h1>
</div>
<div>
<?php the_content(‘<p>Read the rest of this page &raquo;</p>’); ?>
<?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>
</div>
</div>

<?php endwhile; endif; ?>

<div>
<?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?>
</div>
</div>
<?php get_footer(); ?>

I made this in a notepad and saved it as nosidebar.php

Related posts:

Related Posts

This post was written by...

– who has written 188 posts on Wordpress Website builder.

I am addicted to internet marketing and making money online. Who wouldn't want to live that life? I started out with one website as a hobby and now have over 20. Come and join in the fun and share your knowledge about building Wordpress Websites. If you are interested in guest posting for this website click here to see more details.

Submit your own guest post now!

{ 28 comments… read them below or add one }

Mark February 8, 2012 at 12:20 pm

Hello, Mitz.
I’m using the them called Basic2Col.
I’ve attempted it again and still no luck.
Any help would be appreciated.

Thanks,

MH

Reply

Mark January 9, 2012 at 8:37 am

Hi, Mitz.
I appreciate the video you’ve created to cover this topic and provided the code as well. However, I have followed the directions and it did not work.
I’ve gone back and deleted the php file from the server from my hosting account, re-created it, and uploaded the file again and still the page shows up blank.
Any ideas as to what could be the issue?

Thanks

Reply

mitz January 9, 2012 at 11:17 am

It could be as simple as one < out of place. Many themes come with a nosidebars template installed now.. Which template are you using?

Reply

Danny September 18, 2011 at 7:43 pm

Mitz, you make me feel like a noob (probably because I am).
I don’t get it.
But I can’t watch the video so that doesn’t help anyway.
Can’t think of any use for it now anyway, just wanted to learn because you never know. :)
Danny recently posted..Remington RM1015P 10-Inch 8 Amp Electric Pole chain Saw

Reply

mitz September 18, 2011 at 8:31 pm

Hi danny
i have fixed the video now..
You only need this for themes that do not give you a page template included.. Most do now but you might come across the odd one that doesn’t.

Reply

Danny September 18, 2011 at 8:41 pm

Oh ok, I don’t need it then (at the moment). But when I do, I know where to learn it :) .

I can’t see the video, not because it is broken but because youtube is blocked in China.
Thanks anyway!
Danny recently posted..Poulan Pro PP446ET 8-Inch Gas Powered Pole Chain Saw

Reply

Den April 1, 2011 at 9:53 am

Nicely done…simple tutorial for beginners…
Den recently posted..Unable to access plugin settings page in admin dashboard

Reply

Simon March 10, 2011 at 8:24 am

Yes. I created the template and spread the content to fit the full width but the bottom of the post ends abruptly and the grey bar would finish it off nicely. I can get it to appear at the bottom but it’s wider than it should be, ie not fitting inside the content div.

Reply

mitz March 10, 2011 at 11:33 am

I thought that grey bar would be part of the footer?
Can you post your original page.php here so I can get a better idea?

Reply

Simon March 10, 2011 at 2:40 am

Hi. Firstly thanks for the tutorial.
I am using the WhitehousePro theme and I have got this to work fine except one thing.
Where would I put [code][/code]

I you take a look at my site, below each page is a grey bar with the words “Go To Top” This is what the above code creates but I cant figure out where to put it in the code you supplied.

[code]

<div id="post-">

[/code]

Reply

mitz March 10, 2011 at 7:32 am

Did you make a page without this grey bar and you want it to show up?

Reply

Jen October 25, 2010 at 7:44 am

Mitz,
I got it to work! For some reason the quotes in the original notepad file didn’t convert properly — when I re-typed them in directly in wp it worked great. :-) I do still have one issue though — for some reason removing the sidebar also seems to make the footer move about half way up the page. I want to keep it, but add some space — is there a simple way I can add some blank space there between the end of the text and the footer?

Reply

mitz October 25, 2010 at 8:06 am

oh great….I will have to do a post about copying code…It is best to paste it into notepad and then copy it again…you just don’t think to mention this….

That’s my next post.

Reply

Jen October 25, 2010 at 6:32 am

They’re free themes — both available on the official wordpress site.

Reply

Jen October 23, 2010 at 10:17 am

Sorry, that first theme should read OfficeFolders 1.4 — I gave you the designers name by mistake.

Reply

Jen October 23, 2010 at 10:14 am

Hi Mitz.

Thanks for taking the time to do this! I’ve tried your code with 2 different themes — Themocracy and Cordobo Green Park 2 — and both times when I select the nosidebar.php file I’ve uploaded, I just get a blank page. I’m clueless about how to tweak or whether it won’t work at all with these themes as I’m fairly new to wp. Help! Any suggestions much appreciated!

Reply

mitz October 23, 2010 at 3:23 pm

Hi Jen
Are these free or paid themes?

Reply

Jerry August 27, 2010 at 10:22 pm

Hi Mitz,

I don’t see that option in the latest WP install. I’m using Whitehouse as well (just updated earlier this week).

When I try your page template video I’m getting a return page that’s entirely blank.

I do see the name nosidebar in the templates selection box.

I’m using Firefox on the most current WP as well. Site is hosted on my server.

Thanks!

Reply

mitz August 29, 2010 at 12:23 pm

Hi Jerry
have you got the same free theme as me? There may be a pro version. If you do have the same, please try from the start again step by step…Please let me know how you go.

Reply

mitz August 19, 2010 at 8:27 am

Hey guys…the default Wordpress theme now has this option….so when you are making a post you can choose a template without a sidebar…how great is that. I also notice a lot more themes doing the same thing…Soon this will be the minimum standard or basis included in a bare Wordpress theme.

Reply

Mauricio Pisegna July 8, 2010 at 10:23 pm

omg! i have no clue.. will someone tell me how to get this page saved inside my ipod so i can show my little sister?

Reply

mitz July 8, 2010 at 11:35 pm

Maybe you could just send her the url of the page. (the address)

Reply

monty July 4, 2010 at 11:13 pm

I tried this and all I kept getting was just a blank page with no content.
Does the work for all themes in wordpress?
monty recently posted..Thinking The Right Way

Reply

mitz July 6, 2010 at 3:52 am

All themes are different, however this code fits into many of them. If it doesn’t work you can try editing the code a bit…Look at the page.php to get an idea of how the code is structured.

Reply

Bill June 23, 2010 at 7:51 am

Thanks, worked great fast and easy, it took longer to watch the video and got it right in one try.

Reply

mitz June 23, 2010 at 9:48 am

LOL…yeah I am sorry it took so long…but I try not to leave anything out… Glad it worked for you.

Reply

Lars Inge Holen November 8, 2010 at 9:45 pm

Hi,

I copied the code from your page and named the site nosidebar.php

Why do I get this error?

Parse error: parse error in C:\wamp\www\wordpress\wp-content\themes\twentyten\nosidebar.php on line 15

Reply

Shan July 22, 2011 at 4:19 pm

i got same error on line 17 tho…

Reply

Leave a Comment

Please use your REAL NAME@KEYWORDS or just your REAL NAME to get approved. Worthless generic comments will be deleted. Please see these tips on how to get approved.

{ 1 trackback }

Previous post:

Next post: