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 »</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




{ 27 comments… read them below or add one }
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
It could be as simple as one < out of place. Many themes come with a nosidebars template installed now.. Which template are you using?
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
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.
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
Nicely done…simple tutorial for beginners…
Den recently posted..Unable to access plugin settings page in admin dashboard
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.
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?
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]
Did you make a page without this grey bar and you want it to show up?
Mitz,
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?
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.
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.
They’re free themes — both available on the official wordpress site.
Sorry, that first theme should read OfficeFolders 1.4 — I gave you the designers name by mistake.
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!
Hi Jen
Are these free or paid themes?
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!
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.
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.
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?
Maybe you could just send her the url of the page. (the address)
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
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.
Thanks, worked great fast and easy, it took longer to watch the video and got it right in one try.
LOL…yeah I am sorry it took so long…but I try not to leave anything out… Glad it worked for you.
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
i got same error on line 17 tho…
{ 1 trackback }