Forums

How to show a post teaser on a template with only one post (5 posts)

  1. yuletide
    Member
    Posted 3 years ago #

    (This may belong in "advanced" but as of 5 minutes ago only moderators could start new threads there...)

    Hi, so I can't get post teasers to display on my front page unless I actually put "the_excerpt" in my code (which I don't want to do).

    The homepage is a normal "page" with its own content (mission statement, etc) but then I added in some extra PHP to the template to pull the most recent post. Unfortunately, that post always shows up in its entirety... (
    http://codex.wordpress.org/Template_Tags/the_content)

    Here's the code:

    <?php $latestPost = new WP_Query();
    $latestPost->query('showposts=1');
    while ($latestPost->have_posts()) : $latestPost->the_post(); ?>
    <div id="post"> etc...
    <?php the_content( __( 'Read More <span class="meta-nav">&raquo;</span>', 'sandbox' ) ) ?>
  2. kennethwatt
    Member
    Posted 3 years ago #

    Are you wanting help with:

    I'm worried that somehow wordpress thinks its a single-post page due to the way I constructed my queries?

    or

    Hi, so I can't get excerpts to display on front page unless I actually put "the_excerpt" in my code (which I don't want to do).

  3. yuletide
    Member
    Posted 3 years ago #

    Both, since the first is my only possible explanation for the second...
    http://codex.wordpress.org/Template_Tags/the_content

    I'm trying to display a teaser even though its a template and only displaying one post...

    EDIT: I've updated the original post to make it a bit clearer, sorry if it was confusing!

  4. yuletide
    Member
    Posted 3 years ago #

    Argh. Tried using the post-teaser plugin: http://wordpress.org/extend/plugins/post-teaser/ but it also thinks the front page is a single post page and never displays the teaser. I tried forcing $single = false in my template but that just crashes EVERYTHING:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 14595 bytes) in /digex/wordpress-content/plugins/post-teaser/post-teaser.php on line 415

    Tried disabling the plugin, but leaving $single=false, and even that doesn't work! Tried changing the query to showposts=3...

    Ahhhh!

  5. blablu
    Member
    Posted 2 years ago #

    Hey. I had the same problem and solved it like this:

    // Get the Posts
    query_posts('showposts=5');
    // Activate Read more...
    global $more;    // Declare global $more (before the loop).
    $more = 0;
    // The Loop
    <?php thematic_navigation_above(); 	?>
    <?php thematic_above_indexloop() ?>
    <?php thematic_indexloop() ?>
    <?php thematic_below_indexloop() ?>
    <?php thematic_navigation_below(); ?>

    For more information look at http://codex.wordpress.org/Template_Tags/the_content

Topic Closed

This topic has been closed to new replies.

About this Topic