How to Make a Custom WordPress Page Template

Posted on Wednesday, 13th May, 2009

In WordPress, there’s an option before you publish a page, to select a template. This option will only show if your theme has page templates. Custom page templates are great if you need a page to look different than other pages on your blog. The whole purpose of having a custom template is to possibly show a different sidebar, a full page width (no sidebar) or totally different HTML in this area. You might need to change your style sheet by adding special classes for your content or sidebars if you do this.

This is how to make a custom page template for your WordPress theme. Instead of showing bits an pieces of code that you can’t visualize together, I’m just going to show what the whole code should look like. Obviously, your code will call your style sheet classes and they will probably be called something other than “main” and “content”. Create a new PHP page and add the code below to the top of the page. You can do this in a text editor or an html editor.  Right after where its says “Template Name:”, type in the name you want your template to be called. That’s the template name that will show up in the drop down box in the page you’re creating.

You can also take your index.php file and copy and paste that into a new file below the reference that goes at the top to get you started. But, doing that really wouldn’t look different than your main site. Once you have your code created (based on what I’ve shown you below) for your page template, save your page as template_name.php (don’t really use the file name I just used, come up with your own name and don’t name it page.php or you will overwrite your page file). Upload that to your theme file and when you edit or add a new page to your WP blog, your template name should now show up in the drop down menu to select from.

Sample Code for Custom Page Template

This code below gives you a general idea of what your page template should look like

phpcodecustomtemplate

 

 

avatar

Your name

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Testimonials

“Stephanie is a joy to work with. Her work is creative, fun and smart. She bends over backwards to accomodate her clients wishes and to bring the desired "look" and feel to a design. Her knowledge of web design is invaluable as she guides her clients through the process of what will work best and get the most effective results. I highly recommend Stephanie to anyone searching for website and small business graphic design assistance.” Jacquelyn Fishman  More >>

All content copyright ©2007 - 2010 Sweet Boutique Design, LLC.- All rights reserved - Terms of Use - Privacy Policy
Nothing on this site is public domain. Do Not Copy.

NO!SPEC - R.I.G.H.T.S - MI Design Firms - Web Design - Women Designer's Group
We're a featured Howell web design company in Michigan web design company directory at Finders - US web designers directory