How do I create a different page style (template) for some pages on my WordPress site?

You can have as many different page styles on your WordPress site as you want. Your main page template is probably called "page.php" or something like that. You'll probably want to start with that page as a basis, unless your new page is completely different!

Open your source template (page.php or whatever it is called on your site) and save it as "template2.php" or something that makes sense for you. The first thing you'll need to do is modify the template name at the top of the page. Sometimes developers don't put the template name at the top of the main template page, so you'll need to add it, if this is the case. WordPress looks for the template name as the first comment in the file. The top of your file should look like this:

<?php
/*
     Template Name: My New Template
*/

Your template name can have multiple words, but keep in mind that it will appear in a drop-down box in your WordPress Admin panel, so try to keep it relatively short and free of weird characters.

Now just go to town on the file! Make whatever modifications you need to make and then save it. Upload it to your theme directory. If you've never uploaded to the theme directory before, it is probably located within your WordPress directory (or your home directory, if WordPress runs your whole site) as wp-content/themes/your-theme-name.

Once it has been uploaded, you can either edit and existing page or add a new page with the new template. To change the template used (assuming you have a standard WordPress Admin layout), look in the "Attributes" box on the right side of the "Add Page" or "Edit Page" screen. Under the "Template" section, just select your new template and voila, you're done! Of course, you should check to make sure your new layout works! ;)

If this process didn't work for you, go back and check the steps carefully; make sure that you added the comment as the first line of the template file and that you uploaded it to the correct place. If you are sure you followed the directions correctly and it didn't work and you'd like some help, please contact me. Or, if you find an error or have a suggestion for improvement, I'd be happy to hear it.

Back to the main WordPress Q&A page