Support » Fixing WordPress » how to make the_content `<!–more–>` work on single page

  • I have set up a page with a template to display all posts from a category. I want it to display only the_content <!--more--> of the post but it always shows the full post.

    I think this is because it does not regognize the multipe posts on the single page and therefore shows the full posts.

    This is somehow similar to the problem at the bottom of this thread, but I can’t get it to work…

Viewing 5 replies - 1 through 5 (of 5 total)
  • hmm… you mention this is happening on a ‘single’ page, so i think you mean a single.php template…

    however, you say it’s a page showing all posts from a category, so i’m assuming it’s a category-X.php template. if so, that’s unexpected…

    from codex:
    using the more like it says: “… when viewed on the non-single/non-permalink web page such as archives, categories, front page, and searches, the post is shown as an excerpt to the more point.”

    basically, if you’re using a single.php template, then it will show the whole loop.

    can you tell me what ‘kind’ of template you are using? single or category?

    I am using a page.php template, like this:

    Template Name: work
    <?php get_header(); ?>
    <div class="narrowcolumn">
    <?php query_posts('cat=18'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    That’s because you want to force WP to do something in a complicated way, instead of using the simple built-in method:
    “to display all posts from a category”
    Any archive.php or category.php template would do what you want.

    Of course, if you had excerpts for your posts, you could replace the_content() with the_excerpt(). I’m not sure if you’re willing to go through the exhaustive measure of copying the text before your <!--more--> and pasting that as your excerpt, but it would seem to work with a minimum of coding. Otherwise, it would seem that you’d need to figure out a way to override WordPress’s default designation of is_page to your page template, but that sounds like a mess.

    thank you, I’ve moved to a category template and everything works fine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to make the_content `<!–more–>` work on single page’ is closed to new replies.