[resolved] How to customize Pages template? (9 posts)

  1. deko
    Posted 9 years ago #

    When I create a new Page, I don't want a sidebar and I want to customize a couple of other things.

    I assume the Page templage is based on a "Single". Is this correct?

    How can I use a different template for Pages?


  2. Austin Matzko
    Posted 9 years ago #

    For pages in general, create a template named "page.php" To make a template and assign a particular page to it, see this.

  3. deko
    Posted 9 years ago #

    Page.php is indeed the file to modify. For starters, I commented out get_sidebar and link_pages.

    But I'll need to make some CSS mods - because the_content of a Page is generated in the same way as a post.

    But if I want a custom nested ordered list, for example, I have to change the behavior of BOTH regular posts AND the Page - because <ol> is redefined in the .entry class.

    Nesting another class will not work here. So I'll need something like a <page-entry> class...


  4. moshu
    Posted 9 years ago #

    1. You can have hundreds of Page templates - if you want :)
    2. You can use all kind of specific div classes and id's in those templates, and define them in your stylesheet - so a Page can look totally different.
    It's just a little bit of work, but it can be done!

  5. deko
    Posted 9 years ago #

    That "little bit of work" is largely discovery since I'm relatively new to WP (but fairly well-versed in CSS, PHP and HTML).

    Can you give me a hint on how I can create Pages based on different templates?

    I was successful in changing a couple of lines in page.php:

    For example: entry to page-entry and commenting out link_pages:

    <div class="page-entry">
    <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    <?php //link_pages('<strong>Pages:</strong> ', '
    ', 'number'); ?>

  6. moshu
    Posted 9 years ago #

    The link filosofo gave you (Page Templates) describes fairly well how to create successive Page templates - besides the default page.php. That one doesn't have to have the additonal lines at the top - all the others will need it. [see the Codex]

    After having 2, 3, 4...57 templates, in the Write Page area you'll have a dropdown menu to choose a template for the new Page you are creating. It cannot be simpler.

    As to what to have in the templates and what kind of markup to use around the Loop - it is entirely up to you. You were/are on the right track by defining a "page-entry" class. In the next template you can have "my-red-entry" calss and defined in the CSS as bg: red etc.
    And you always pick the proper Page template when creating a new Page.
    Does this help?

  7. deko
    Posted 9 years ago #

    Ah, I see... use the drop-down to select a page template.

    more to learn... :)

    I'll figure it out.

    It would be nice if WP shipped with a few (no more than 3) different page templates (each with some minor difference in appearence). So users would see the 3 different selections in the drop-down, and could hack each template with impunity.

    Anyway, thanks for the tip!

  8. moshu
    Posted 9 years ago #

    Don't forget that template files (including Page templates) are theme specific.
    The Default does have several Page templates:
    The Classic has none.

  9. bugsmi0
    Posted 9 years ago #

    for page templates can we have a separate theme folder for it ? i have not read in the docs about creating another folder with its own images and stylesheet, do the added page templates remain in the main theme folder ?

Topic Closed

This topic has been closed to new replies.

About this Topic