• Resolved melibeth2001

    (@melibeth2001)


    I’m attempting to create a “static” page template that will display only the content of the Page usting the template at any one time. I’d like the template to be utilized throughout my site and I expect to have MANY of these pages and sub-pages.

    I’ve searched for something other than the loop to display Page content in the template (code below) to no avail. I understand that the content is displayed the same way a post content is displayed. I just need it to be limited to the page the template is currently being applied to. Make sense? Help?

    Thanks,
    -Mel

    —————— Template Page Code Below ——————

    <?php
    /*
    Template Name: StaticPage
    */
    ?>
    <?php get_header();?>
    <div id=”main”>
    <div id=”content”>
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class=”post”>
    <h2 id=”post-<?php the_ID(); ?>”><?php the_title();?></h2>
    <div class=”entrytext”>
    <?php the_content(‘<p class=”serif”>Read the rest of this page »</p>’); ?>
    </div>
    </div>
    <?php endwhile; endif; ?>
    </div>
    <?php get_sidebar();?>
    <?php get_footer();?>
    </div>

Viewing 3 replies - 1 through 3 (of 3 total)
  • If you have a file in your theme’s folder named page.php, then it will be used throughout your site automatically for all “static” pages. Only use a page template if you want some pages to styled differently / have different sidebar(s) / exclude content / etc.

    I just need it to be limited to the page the template is currently being applied to. Make sense? Help?

    This is done automatically when someone navigates to the address of a particular page: WP only retrieves the content for the particular page and displays that inside “The Loop.”

    For your site http://www.inourownwordsmcc.org, if you navigate to the About page (at http://www.inourownwordsmcc.org/?page_id=2), WP will only grab the content and meta data for the page with an ID equal to “2” and nothing else. There’s nothing you have to do. This is automatic.

    Please take a look at Template Hierarchy and Pages for more info.

    As mentioned above, look at the Template Hierarchy section in the Codex.

    But what you want to do, from the sound of it, is create a special template for a page. You wouldn’t name this page.php — you’d give it its own name, like myspecialpage.php. Then, when you write a page, you’d assign that page to your special template, instead of the default page.php. Then it would pick up your formatting.

    You’ll find out more in the Codex — but it helps to know ahead of time what you’re looking for….

    Thread Starter melibeth2001

    (@melibeth2001)

    Many thanks…I got it.

    -Mel

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Page Template Help – Single Page Content’ is closed to new replies.