WordPress.org

Ready to get started?Download WordPress

Forums

how to make the_content `<!--more-->` work on single page (6 posts)

  1. markusz
    Member
    Posted 8 years ago #

    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...
    http://wordpress.org/support/topic/34158

  2. nearlythere
    Member
    Posted 8 years ago #

    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."
    http://codex.wordpress.org/Customizing_the_Read_More

    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?

  3. markusz
    Member
    Posted 8 years ago #

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

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

  4. moshu
    Member
    Posted 8 years ago #

    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.

  5. muraii
    Member
    Posted 8 years ago #

    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.

  6. markusz
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.