Can't get excerpt to appear. (3 posts)

  1. danny_getextra
    Posted 3 years ago #

    I'm trying to make a page where all the posts appear, at the moment I've managed to make a custom template and make a loop that pulls in all the posts. However I can't seem to get the excerpt to work?

    link to what I have working at the moment.


     * Template Name: All Posts
    <?php get_header(); ?>
    <div class="content-break">
            <div class="wrapper">
                <div class="one notopmargin post-wrapper">
    $debut = 0; //The first article to be displayed
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    <?php the_excerpt(); ?>
    <p><?php the_title(); ?><a href="<?php the_permalink(); ?>">Read More...</a></p>
    <?php endforeach; ?>
    <?php endwhile; ?>
            <div style="clear:both"></div>
    <?php get_footer(); ?>

    Any idea's and I'll gladly change.


  2. Michael
    Forum Moderator
    Posted 3 years ago #

    add setup_postdata($post); to your code, as shown in the example in the Codex http://codex.wordpress.org/Template_Tags/get_posts#Examples

  3. danny_getextra
    Posted 3 years ago #

    Fantastic! This worked just fine. I see my mistake I'm still learning though.

    Many Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.