• Hi

    I have added the following code to my page.php file in order to list my post summaries at the bottom of page ID 10:

    <?php if(is_page(10)){ include(TEMPLATEPATH . '/homepage.php'); } ?>

    In homepage.php I want to call for a summary of the posts. Is this the best way to do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I think the best way would be to create a different page template instead.

    Thread Starter robhav

    (@robhav)

    Great have done that. Have also added code to show the last ten posts. I can’t seem to find any info however on adding a summary of each post underneath the titles?

    <ul><?php $myposts = get_posts('numberposts=10');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?></ul>

    How about <?php the_excerpt(); ?> ?

    Thread Starter robhav

    (@robhav)

    That seems to just display the current page text.

    So I get:

    – News Title 1
    Current Page Text
    – News Title 2
    Current Page Text

    I need to be able to display the excerpts of the particular news stories.

    i.e.
    – News Title 1
    News 1 Text Excerpt
    – News Title 2
    News 2 Text Excerpt

    Thanks again for your replies by the way… appreciate it.

    You can use the setup_postdata(); function to setup all the necessary variables… like this:

    <ul><?php $myposts = &get_posts('numberposts=10');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    <li>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <br /><?php the_excerpt(); ?>
    </li>
    <?php endforeach; ?></ul>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Manipulating Theme Templates’ is closed to new replies.