• I’m creating a custom template to display the summaries of all posts on a single page (using: <?php query_posts(‘showposts=-1&orderby=title&order=ASC’); ?>). All posts are being listed, but the full text rather than just the summary.

    I’ve even tried copying the main index template (which displays the summaries correctly) and adding the query_posts function call — and still the full post is displayed.

    I’ve probably missed something obvious, so hopefully someone will be able to point out where I’ve gone wrong….? (Using WP2 by the way).

    Thanks in advance for any advice.

Viewing 7 replies - 1 through 7 (of 7 total)
  • the_content template tag displays the full content; the_excerpt displays the summary.

    I’ve not ever tried this, but I know you’re getting exactly what you’re calling – the full post.
    Maybe take a quick glance at this page – I think it may be the direction you want to go.
    https://codex.www.ads-software.com/Template_Tags/the_excerpt

    As mentioned, either use the_excerpt() or use the <!-- More --> tag.

    personally, I find the latter a lot easier…

    Thread Starter nolongeractive

    (@jrbriggs)

    Sorry, I should’ve mentioned. All my posts are using <!--more-->, plus I’ve tried using the_excerpt, and it doesn’t seem to work either.

    I’ve basically created a page (with no content), and set the template to my custom template (I’ve pasted the top part of it below).


    <?php
    /*
    Template Name: Display All
    */
    ?>

    <?php get_header(); ?>

    <div id="content" class="narrowcolumn">

    <?php if (have_posts()) :
    echo "USING DISPLAY ALL TEMPLATE";
    query_posts('showposts=-1&orderby=title&order=ASC');
    ?>

    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="entry">
    <?php the_excerpt(); ?>
    </div>

    link to the page?

    Thread Starter nolongeractive

    (@jrbriggs)

    I don’t have it running on an externally accessible server unfortunately.

    Happy to post/email/whatever the full template file, if someone wants to try it for themselves. And I guess I should try a fresh WP install, and try it on that (since I’ve got a bunch of experimental stuff on the current install)

    Thread Starter nolongeractive

    (@jrbriggs)

    Finally figured out the problem. I think I misread whatever reference I found that suggested using query_posts — I assumed it loaded posts ready to use in the_loop, whereas it actually just displays them. So what I thought was a problem with the_excerpt was actually 2 different sets of behaviour:

    1) query_posts was dumping all posts into the page and,
    2) the loop code starting with while (have_posts()) : was actually returning nothing, so the_excerpt function wasn’t actually being executed.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘summaries not working in custom template’ is closed to new replies.