How to Create Page Templates in WordPress

What do you do when your blog covers more than one topic (let’s say, wordpress hosting and guides on how to install Ubuntu), while your audiences all hang around on different social media sites? Seeing a Sphinn logo in the top left of your content isn’t exactly appropriate when you’re targeting Digg, right? To solve that problem, you could use multiple page templates to help improve your Diggs or Sphinns.

As part of a series of articles on advanced WordPress SEO, I’m going to show you how to create multiple page templates that feature different social media buttons in your top left hand corner. Take a look at these two different page types to get an idea of what I’m upto.

A note on conditional tagging vs creating new page templates

Before you read on: if you’re just looking to create a new page template in WordPress, read on. If you’re looking to use conditional tagging to display certain social media bottons based on a blog post category, you’ll need to go here: Only display the Sphinnit button on an SEO post. Right, let’s continue, shall we?

We’re going to create a new page template specifically to display the Sphinnit button, and repeat the process to create a page template for the Digg this button.

How to create a new page template in WordPress

We’re going to copy your page.php file, rename it, and use a little bit of PHP to tell wordpress there’s an extra page template available, which will display in the “Page Template” drop down in the page editor. Here’s what it looks like:

1) FTP to your WordPress host and navigate as follows:


2) Copy page.php and stick it on your desktop.

3) Open the file in your favourite editor.

There’s a clever little bit of php you need to insert at the very top of the file, which can be used to name the template you’re creating. Without a name, WordPress assumes that the new file you’ve created is a default template which is not great for your pages or WordPress!

In this example, I’ve given my page template the rather imaginative title of “SEO-Content-page”. The code looks like this:

Template Name: SEO-Content-page

Insert it before the <?php get_header(); ?> tag.

4) Let’s finish the SEO content page. Remember the Sphinnit button? the code you need to insert into your new SEO-page.php file is as follows:

<?php show_sphinnit(); ?>

Place this code directly before the_content tag, so it looks like this:

<?php show_sphinnit(); ?><?php the_content(); ?>

When you’ve inserted your code, save the page.php file with a new filename, say, SEO-page.php and copy it back into your theme directory via FTP. don’t forget that your Sphinnit logo will display wherever you have set it to via the plugin settings in your wp-admin.

You now have two versions of a page template. One for SEO content and the original, untouched page.

If it’s useful, I’ve uploaded the code for my SEO-page.php which you can download here. Note I’ve created a table which has stumbleupon, reddit, mixx and digg this buttons.

When you’re ready to create a new page specifically for Digg, repeat the steps above. When you’re ready to insert your code, including the top left alignment, the Digg this button code looks like this:

<div style="float: left; margin-right: 10px; margin-bottom: 2px;">
<script src="" type="text/javascript"></script>

Here’s the full page code for my Digg page. Hope you find it useful! :-)

Have We Been Helpful?

Builtvisible are a team of specialists who love search, SEO and creating content marketing that communicates ideas and builds brands.

To learn more about how we can help you, take a look at the services we offer.

Stay Updated: Sign Up for New Blog Alerts

Follow: | | |

Tags: , | Categories: Technical

23 thoughts on “How to Create Page Templates in WordPress

  1. Erika says:

    I sphunn your article, but I also thought I’d post here that if you’re creating multiple templates only to accomodate this one change, you might be more interested in conditional tagging, which basically says:

    [insert details for this category]

    [insert details for other categories that dont fit into the previous description]

    That’s not verbatim, but that’s the general idea. I believe the WP codex explains this in pretty decent detail, though. You can always e-mail me if you have any questions. :)

  2. Hi there – thanks for your Sphinn! I actuall covered conditional tagging here – your suggestion is great but for the application I’m referring to it certainly makes a lot of sense to have a few extra page templates.

  3. These are really great pointers Rich..^^ thank you so much for being so generous.

  4. Utah SEO says:

    Great tutorial! I definitely think that blogs that receive a lot of traffic should implement the social media buttons because it can be a great way to add some extra votes.

  5. Hi Richard,

    I actually picked this up through Sphinn. It’s a good article, although as a comment on Sphinn points out, it’s only useful for pages. Most bloggers will be using posts.

    Personally, I think the use of Custom Fields is the best way to go. Edit your theme so it checks for the presence of a Custom Field and shows the appropriate social media buttons depending on the setting of that field. Then you just need to add a Custom Field to a post that you want the buttons to appear and hey presto.

    That would be a great article if you write up how to do that!

    Please note, the above article is great too, I know this sounds a little negative, but a post solution would be even better.

  6. @stephen_Cronin @Erika – You both hit the nail right on the head. Since Erika’s comments on conditional tagging for the single.php pages I’ve been working on a revision article. Thanks all for your comments and really appreciate you dropping by :-)

  7. Hi i have a blog site, Can i get good PR without listing my site in Web directories like Yahoo?
    I am planning to put my links in paid PR>5 sites. Will that be sufficient to get good PR?
    To get PR>4, How many PR>5 sites should be having my site’s link?
    Thanks in Advance.

  8. gusde says:

    sorry the code disappear



  9. Yeah thanks because you’re trying to paste .php code into my comments! It sounds like you’re not naming the new page properly. Are you adding the template name code?

  10. GoogleBot says:


  11. Rowland says:

    Hi. A bit off-topic, but this seemed to be the closest thing I could find to a post dealing with my question, which is: how do i give my new pages comment fields? at the moment they don’t come up with them and i’m a bit nervous about using the custom fields.

    thanks – sorry to bother you


  12. Thanks for a nice and informative site. Somehow I was drawn to reading the post and I learned a lot. Have a nice day!

  13. Scott Bussey says:

    Great article – just what I was looking for

  14. Hi Great post thanks for sharing. finding it too easy now to create extra templates for my child theme

  15. Very helpfull. Thanks a lot.

  16. A. H. Ansari says:

    Great article dude very useful site. thanks.

  17. Brian says:

    Thank you for this article – just what I was looking for. I am offering 4 courses of study on my site. My theme, FlipBlog, has template pages. I can use the same template for all 4 pages but I wanted each one to only show the content relating to that course (category). I also wanted to use custom menus on each page – so once the reader reaches the Page 1 course, the custom menu widget shows a menu for just that course. My challenge is I can only add the custom menu to the template – I think – not to specific pages. The other acceptable alternative, if I can find one that works with my theme, would be to use a collapsible sidebar menu – an outline that shows header categories and then reader can drill down into the coure into the course sub categories. Anyway, between these ideas here, I think I can accomplish what I need. Thank you all for sharing. Brian

  18. Kelly says:

    Awesome post! Believe it or not, I have only JUST had the opportunity to use WordPress templates, and have never taken the time to figure out how to create them or even why. So thanks for this!!!

  19. Mac says:

    Hi Richard,

    Ive figured this out here, but im wondering if I can adapt it – or if I should be heading in this direction to do the following.

    In my header files on sites I have some geo script which allows countries to access the site whom the content is targeted for and directs other countries somewhere else. Really what I want to do with those “other countries” is direct them to another page on my site that is able to use wordpress plugins.

    I dont want my theme or anything just a plain white page which I write information on, add links, images etc – but I want the plugins to work because at this point I need to geo-target the code on this page depending where they are from and this requires me to use a WordPress plugin.

    So basically I need to create a blank template page which doesn’t load anything except for WordPress frame work so I can call upon the plugins with their “[ ]” shortcode symbols – is this possible?

    – Mac

  20. Gabriela says:

    Awesome post Its was great to find exactly what I was searching for..and its work!!!
    ! thanks a lot…!!!

  21. Does this still work for the latest version of wordpress?

  22. Joel Felkins says:

    I found this article to be really helpful. Thanks.
    I will be using it to make a custom home page.


  23. maja says:

    Is there any way to add a new .php page right from the WordPress dashboard? I’m asking this because I’m not that experienced with cPanel.

Leave a Reply

Your email address will not be published. Required fields are marked *