WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. danny_getextra
    Member
    Posted 1 year 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.

    http://goo.gl/aC8TO

    <?php
    /*
     * Template Name: All Posts
     */
    ?>
    
    <?php get_header(); ?>
    <div class="content-break">
            <div class="wrapper">
                <div class="one notopmargin post-wrapper">
    
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    
    <?php
    $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>
           </div>
            <div style="clear:both"></div>
        </div>
    
    </div>
    <?php get_footer(); ?>

    Any idea's and I'll gladly change.

    Thanks

  2. alchymyth
    Forum Moderator
    Posted 1 year 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
    Member
    Posted 1 year 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

Tags

No tags yet.