First time visitor? Then start here and learn more about Blog Marketing Academy!
First Name Last Name Email

How To Use a Custom Page Template In WordPress

Sometimes, it is useful to give a particular section or page of your blog a completely different look and feel from your regular blog theme. It is very easy to do in WordPress.

For example, over on PCMECH I wanted to have a sales page for our premium program. I wanted to make it long-form style and without the usual clutter of the main site theme. As I have stated in the past, when you are in selling mode on your site, you want to get your reader to read the offer and make a yes/no decision. Having a top and bottom menu and a full sidebar is a lot of distraction and a lot of potential ways out of your sales letter without them making a choice on your offer. The solution is to remove all the clutter.

My sales page at PCMech is set up as a page in WordPress. That page, though, uses a completely custom template just for that page. The “how” is actually pretty easy…

Want To Learn How To Customize WordPress?

David, founder of Blog Marketing Academy, will be delivering a live 6-workshop series starting in August – Demolishing The Blogging Technical Confusion. Covering theme customization, custom templates, the best plug-ins, marketing integration, etc. Click To Learn More.

Creating a Custom Page Template in WordPress

All WordPress themes have a file called page.php. This is your template file for all pages you have on your blog (remember, pages are distinctly different than posts). The page.php file is your default page template. To create a new one, just open that file in any text editor then “save as” a different file name. In my case, I named the template for my sales page signup_page.php.

Now, at the very top of this new file, you’re going to want a block of PHP code as follows:

<?php
/*
Template Name: [your page name here]

*/
?>

Picture 1This is a PHP comment. Leave the “Template Name:” in place, but you need to change the name of the page. Once you have done that, upload this new file to your blog theme’s folder.

Then, in WordPress, when you go to add or edit a page, scroll way down and you’ll see a setting for “Page Template”. You should see your new page template listed in the dropdown, using the name you entered above. To the right, you can see what my dropdown list looks like in my own WordPress admin panel. I have many different custom page templates in my system, all for different purposes.

Customizing Even Further

At this point, you would have a custom page template, but it would be an exact duplicate of your default page template. So, you would need to customize it. For example, if you want to get rid of the sidebar, just remove the the following line from your template:

<?php get_sidebar(); ?>

You can change any other HTML in this file that you want.

If you want to include different a different header, you would need to hack the code just a bit. By default, the get_header() and get_footer() functions include the default headers and footers for your theme. However, you can replace these with custom PHP includes to any file you want. For example, you could replace:

<?php get_header(); ?>

with this:

<?php include(“header_new.php”); ?>

This would include the file header_new.php from your theme as your header. You would, of course, need to create a file called header_new.php and alter the HTML to make that your new header file for that page.

You can do this same thing for your footer or even your sidebar if you want to include a different sidebar.

Wrapping It Up

The WordPress template system is insanely customizable once you know how to do it. Above is how I have gone about it for my sales page. I have a custom page set up, and it includes a custom header and custom footer (both with stripped down options). I left the sidebar out. In my case, I even put the HTML for the content of the page into the template itself. Inside of WordPress, the content field is blank. I just selected the custom page template, saved the page, and now my signup page works quite well.

Repeat the same basic process for any page of your blog that you want to have a custom appearance. It is so much easier than trying to pack complicated HTML into the editing field of WordPress.

Happy customizing!

From The Academy

How To Step Into Your A Game"Blog monetization" is a lot more difficult than people think. We're going to move past that - and into developing a REAL business model which can actually earn a sustainable income. By the end, you'll KNOW.

Learn More

 

Got a Question or Comment?

  1. Great post, David; I’ll be using a similar approach for another blog I’m building.

    A home page (home.php) is another example of when you might want to use this approach. You may want to have a welcome message, or a special banner without the sidebar or navigation bar getting in the way.

  2. Great post, David; I’ll be using a similar approach for another blog I’m building.

    A home page (home.php) is another example of when you might want to use this approach. You may want to have a welcome message, or a special banner without the sidebar or navigation bar getting in the way.

  3. Awesome post…. this is definitely a sexy tutorial…. it has many applications…. When i create niche sites, sometimes the sidebar can be filled with clutter that can be distracting people from buying… now i can get rid of those sidebars, but still enjoy the benefits of wordpress.

  4. Awesome post…. this is definitely a sexy tutorial…. it has many applications…. When i create niche sites, sometimes the sidebar can be filled with clutter that can be distracting people from buying… now i can get rid of those sidebars, but still enjoy the benefits of wordpress.

  5. Wow..I’ll try that out on my wordpress blog – http://www.sexacademy.wordpress.com

  6. Wow..I’ll try that out on my wordpress blog – http://www.sexacademy.wordpress.com

  7. This is exactly what I need to do, thank you!

    If anyone can help a complete WordPress newbie, I cannot figure out how to access the page.php file. Do I need to have one of the upgrades installed, or host this on my own domain to do so? Is it possible to access these files via FTP?

    I apologize if this is hijacking at all, thought an answer might help others like me.

  8. This is exactly what I need to do, thank you!

    If anyone can help a complete WordPress newbie, I cannot figure out how to access the page.php file. Do I need to have one of the upgrades installed, or host this on my own domain to do so? Is it possible to access these files via FTP?

    I apologize if this is hijacking at all, thought an answer might help others like me.

  9. Okay, answering my own question… I am downloading from wordpress.org and will install on my own server.

  10. Okay, answering my own question… I am downloading from wordpress.org and will install on my own server.

  11. Dave, thanks for post.

    A quick question, do you have to do anything to the stylesheet at all? I tried to remove my right sidebar, but my content is still on the left with big white space on the right, as if the right sidebar is still there but invisible.

    Thanks

  12. Dave, thanks for post.

    A quick question, do you have to do anything to the stylesheet at all? I tried to remove my right sidebar, but my content is still on the left with big white space on the right, as if the right sidebar is still there but invisible.

    Thanks

  13. Yeah, you’ll need to adjust your stylesheet so that the content column is the full width of your theme.

  14. Yeah, you’ll need to adjust your stylesheet so that the content column is the full width of your theme.

  15. Nice post. Thanks for the tip ;)

  16. Nice post. Thanks for the tip ;)

  17. Not sure that this exactly applies to what you were talking about above, but you do seem to know a lot about WP… I’m a blogger person thinking about switching to wordpress, but it looks like you’re not able to edit the html code of the blog layout, which I’m sort of attached to being able to do… it looks like the only thing editable is the CSS code, which I’m not familiar with (yet). This seems pretty limiting- you HAVE to use one of their templates?

    Thanks for any advice- I’m diving into this whole web-page editing thing and I’m in a little over my head at the moment!

  18. Not sure that this exactly applies to what you were talking about above, but you do seem to know a lot about WP… I’m a blogger person thinking about switching to wordpress, but it looks like you’re not able to edit the html code of the blog layout, which I’m sort of attached to being able to do… it looks like the only thing editable is the CSS code, which I’m not familiar with (yet). This seems pretty limiting- you HAVE to use one of their templates?

    Thanks for any advice- I’m diving into this whole web-page editing thing and I’m in a little over my head at the moment!

  19. It appears that page templates are gone in the latest WordPress release (2.8). I am not sure why I cannot find the page template drop down now.

  20. It appears that page templates are gone in the latest WordPress release (2.8). I am not sure why I cannot find the page template drop down now.

  21. I’m sorry – I just found the solution – Some people are having this problem and not others. http://wordpress.org/support/topic/190138

  22. I’m sorry – I just found the solution – Some people are having this problem and not others. http://wordpress.org/support/topic/190138

  23. David, this is a “next level” tutorial for me. About 6 months ago, I finally jumped in to WordPress blogs and I can’t believe how good they are for SEO. The problem I’ve had is that I’ve wanted that customizable hybrid of being able to make a static web page when I want, then utilizing the regular blog structure when I needed it.

    Thanks!

  24. David, this is a “next level” tutorial for me. About 6 months ago, I finally jumped in to WordPress blogs and I can’t believe how good they are for SEO. The problem I’ve had is that I’ve wanted that customizable hybrid of being able to make a static web page when I want, then utilizing the regular blog structure when I needed it.

    Thanks!

  25. Finally someone I can understand.
    Thank you, thank you, thank you!
    John Turner

  26. Finally someone I can understand.
    Thank you, thank you, thank you!
    John Turner

  27. Hi David,

    Now this is smething i have wanted to do for some time now. So i guess with your instructions and some coding i best go do it.

    Thanks for sharing this, its great to find gems like this just when you need them.

    Kevin

  28. Hi David,

    Now this is smething i have wanted to do for some time now. So i guess with your instructions and some coding i best go do it.

    Thanks for sharing this, its great to find gems like this just when you need them.

    Kevin

  29. I’m building a blog about my travels in Europe. This will help enormously. Your advice is much appreciated.

  30. I’m building a blog about my travels in Europe. This will help enormously. Your advice is much appreciated.

  31. Eric Graudins says:

    Thanks for this useful explanation of what to remove in WordPress pages.
    Other instructions I’ve seen take 5 times as much space to say the same thing.
    Cheers, Eric G.

  32. Eric Graudins says:

    Thanks for this useful explanation of what to remove in WordPress pages.
    Other instructions I’ve seen take 5 times as much space to say the same thing.
    Cheers, Eric G.

  33. That’s a good point about right or left margin clutter…especially when making a sales presentation. Sometimes we think noise looks cool and maybe so but it only serves to distract from the sale.

  34. That’s a good point about right or left margin clutter…especially when making a sales presentation. Sometimes we think noise looks cool and maybe so but it only serves to distract from the sale.

  35. Great stuff for a short tutorial. It looks to me like you’ve included everything needed (minus the cussing I might engage in) for a new look on my blog.

  36. Great stuff for a short tutorial. It looks to me like you’ve included everything needed (minus the cussing I might engage in) for a new look on my blog.

  37. yes, remove sidebar but what is left is a big space on my custom page’s side. what to do to expand the content to the side, please tell us more. thanks for great post.

  38. yes, remove sidebar but what is left is a big space on my custom page’s side. what to do to expand the content to the side, please tell us more. thanks for great post.

  39. chris_prepaidcreditcard says:

    Very good tutorial, it worked for me

  40. Super Dave! Very concise. Thank you!

    Now I will finally be able to get rid of that annoying title at the top of my pages that just repeats the name of the page.

  41. Hi,

    I have done everything what you said and new template is working. But when I log out from wordpress, it is using orginal default template, that is, page.php. Why is so? I am working on wamp on my PC. Could anyone tell where I am wrong.

  42. Sorry Guys, its working now. Actually I forgot to put 'php' with <? in the beginning.

  43. Hi David,

    I wanted to say thanks for this great post. My blog has a bit of a small content area.. about 500px and I wanted to make a special page for search results to properly fit the google search code without changing the rest of the site. I was looking all over and came across your info. I followed your instructions, added a quick few lines of css to the stylesheet and bang… done. While others made this seem very complicated, I was almost afraid to try your solution because it seemed too easy, but worked like a charm :)

    Thanks again…

  44. Thanks for the tutorial. I was searching for info on how to do this and came across your post. You just saved me from having to pay someone at scriptlance to do it for me. I didn't realize that it was so easy… :)

  45. Thanks for the tutorial. I was searching for info on how to do this and came across your post. You just saved me from having to pay someone at scriptlance to do it for me. I didn't realize that it was so easy… :)

  46. thanks a lot, it works immediately after your tut.

  47. Great article! Got rid of side bar, now I just need to see how I can widen text area. http://www.islandconsultingcorp.com/island-cons… is a link to my sites promotional video. I'm helping local businesses branch out into social media and this information can prove very beneficial. Thanks for all you do. I will search to see how to expand my text area/video area, but if you point me in the right direction, I would appreciate it. I believe if you help others get what they want, you can have everything you want.

  48. Ok, I see this is an older article, but I could still use your help! I did exactly what you said, and the sidebar DID get removed, but the page looks messed up. The main part of the page is super small now, and the footer background (which is dark) takes up most of the page, instead of the light background that is supposed to be there. In other words, it looks like the middle part of the page is gone, and the footer is huge. How do I fix this? If there is only one stylesheet for all the pages, I don't want to tinker with that too much because I only want the sidebar removed from the secondary pages.

    thanks!!

  49. johannabartley says:

    WordPress isn't easy to manipulate or it isn't for me at least/ I'll try changing the header files using the code you provided. I really hope it will work.
    Domain name registration

  50. I used this article to add an advertisment into the footer of a page using a Max Banner Ads Pro banner for an individual page sponsor to my site as MBP doesnt support individual page selection. Thanks for your help.

    PS: If there's an easier way using MBP then let me know!! ;-)

  51. Freak! Thank YOU. The other information I got was much more convoluted than this! So simple and it works without a hitch.

  52. Apnataunsa says:

    Apnataunsa Says this is nice post

  53. I am trying to follow the instructions above in order to create a template with no sidebars. However, under my page.php there is nothing that says Where can I find this and how do I get rid of these side bars. I am trying to set up an amazon astore on my site and the sidebars are blocking it.

    Than you for your help

  54. What do I do when there is no in my page.php?
    My pages dp have a sidebar, but I don´t find the line to delete :-(

  55. If you can’t find template in the main edit try in the “Quick Edit” its still there.

  56. Really nice tutorial you have shared in this post and this is great explanation about. Thanks for sharing.

  57. Thank you very much.Really helps to create beautiful pages.

  58. Thanks man. Really helps to create beautiful pages.

  59. Thanks this was very helpful :) 

  60. Thanks for this man. You’re now my go-to wordpress resource :)

  61. Thank you for this post. It’s effective with removing comments. However my template has no “”. I think it’s on functions.php. How can I disable sidebar on this case?

  62. Kindergarten Worksheets says:

    Great post! I have a question-where can I find information
    the formatting of the content of my new pages? Right now in the sidebar is still
    present, even if empty. And I added the text is just plain text right
    now.

  63. thanks a lot. I have been looking for this from long time.. and at last i have got it from your site.. 

  64. You’re now my go-to wordpress resource :) Nice to know that…

  65. Useful tips to help get me going.  I want my site to have a different look if the user views the USA (default) or UK versions.  That means a different home page and sub-pages, but also a different sidebar with content related to the country.  I’m still confused as to whether I need to define different sidebars or not, there are a number of ways to do it I guess.

  66. nice post….

  67. he other information I got was much more convoluted than this! So simple and it works without a hitch.

  68. thanks you so much for explaining it in complete detail . i was looking for that article .

  69. soheila Behyari says:

    thanks , very useful  :)

  70. I’ve created a template but I can’t figure out how to upload it! I’m using the GreenLeaf theme and hosting my site with GoDaddy…could you explain to me how to upload my template to my theme’s folder?

  71. Post is really admirable.Thanks for sharing your view with visitors.

  72. Jennifer says this is nice post

  73. Anh Pham Thi says:

    Nice template, Thank for share template

  74. @David Risley thanx for this useful post…….

  75. Thanks for this great tuts.

  76. Fred Lavios says:

    What is the range for a WP custom page template that would have several separate editable text fields, gallery option (NextGEN plug in already installed), and one static image (changeable image and changeable url) to install as an inside page option?

  77. I have uploaded my custom template in the wordpress. but i cant seem to edit the page. Whatever i edit in the page is not getting updated in my site. Please help

  78. Just want to say your article is as astonishing.

    The clarity in your publish is just cool and that i can suppose you’re a professional on this subject. Well with your permission allow me to grasp your RSS feed to stay updated with drawing close post. Thanks a million and please carry on the enjoyable work.

  79. It helps me alot, Thanks David, You’re amazing guy.

  80. Thanks for this plug–just what I need. Unfortunately, I succeeded with the first step but the customizing further has been an snare not knowing where to eliminate the php entries mentioned so my new template is just a clone of the default!
    Regardless, the search to solve my template problem has led me to you–amazing! You are amazing! But plz give further instructions on how to make my own template so I avoid repetition of my headings in all my pages! Thanks!

  81. Thanks David, nice easy to follow steps of a somewhat challenging barrier. Always appreciated!

  82. Well, dear David, truly the tutorial is simple & clear, but, I guess speed reading just don’t hack it in this business. Going over the whole thing I now can make my own template, sort of, because I don’t like the results of my creations–but I have accomplished much thanks to your tutorials.
    One more thing–my comments are ignored, am I spaming? plz reply.

  83. Excellent and clear article. Thanks so much!

  84. lifesaver. almost went nuts trying to make a form in phpinanypost blah blah plugin. template is so simple.

  85. Nice Post, Can I use Pinterest like layout for my pages.

Leave a Reply

Take the 30 Day Blog Transformation Challenge! 30 Actionable Lessons in 30 Days.

Ready to Get Started? Click To Get Started
First Name Last Name Email