• Resolved Joe Hall

    (@redbmedia)


    I am currently in the process of developing a customized theme for a client. The theme I am creating relies heavely on the template hiarchy and needs to have the ability to display several static pages differently. I have read and re-read this. However, the closest thing that I have come close to, is where it says, “The Page’s selected ‘Page Template'”. So my question would be, how do I select a different “Page Template” for each page. I have already created a “page.php” which works great for displaying every page on the site, but i need to display several pages in a different way. I know that thte solution is probably something very easy that i am just not paying attention to. But I am still confused about this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Assuming you want PAGE1 and PAGE2.

    Create template files, mypage1.php and mypage2.php and then when creating the pages via Administration > Write > Write Page, change the Page Template to point to the respective template (mypage1.php or mypage2.php).

    Resources:
    Stepping into Templates
    Template Hierarchy

    The beauty of templates is that can be completely unique from each other. The page.php file is the default wordpress looks for as the template for your pages but as Michael mentions, creating different ones is easy.

    What I do when creating different page templates is try to name them logically. So, if you have a website with 3 sections (About Us, Services and Contact Us…for the purposes of this example), each requiring a different template, you could name them:

    page_about.php
    page_services.php
    page_contact.php.

    At the beginning of each page, there a few lines of code that tells the system how to separate the templates and make them selectable from the Write Page screen. Using the “About Us” page as an example:

    <?php
    /*
    Template Name: About Us
    */
    ?>

    The other thing I do is create different sidebars for each template, if necessary. Use the same naming convention as your templates. So, create a different sidebar for the About Us page and call it sidebar_about.php. Then call it into the About Us page template as:

    <? php include (TEMPLATEPATH . ‘/sidebar_about.php’); ? >

    You can use this method for any unique items you need to call…headers, footers, etc. Though having a bunch of files can get a little hairy. Once you understand templates you can then learn about conditional statements which can give you much of the same functionality without having a bunch of different files.

    Thread Starter Joe Hall

    (@redbmedia)

    Thank you for your help, however, I already understand everything that you have said. I think that perhaps I need to better clarify my question…

    MichaelH states,

    …change the Page Template to point to the respective template (mypage1.php or mypage2.php).

    My question is how do I do this? When I write a page, I see no options at all to select a template or theme to use….I know that the answer to my problem is problaby quite elementry, but I am still lost.

    You don’t see that because you don’t have a properly structured page template in your current theme folder, for example this code at the beginning of the template:

    <?php
    /*
    Template Name: mypage1
    */
    ?>
    Thread Starter Joe Hall

    (@redbmedia)

    As I assumed, it was something reletively simple that I was over looking. Thank you for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I select different Page Templates’ is closed to new replies.