WordPress.org

Support

Support » How-To and Troubleshooting » Category.php template. 3 excerpted, the rest listed

Category.php template. 3 excerpted, the rest listed

  • Hi!

    I created a custom category.php template because I’d like to display the latest 3 posts of a particular category excerpted, and the rest of the post listed;

    Last post – excerpt […]
    Next to last post – excerpt […]
    antepenultimate post – excerpt […]
    next post
    next post
    next post

    I thought that I could do this with two loops, the first loop trimmed to 3 posts showing the excerpts. The second loop showing just a list with an offset of 3 posts.

    The first problem is that query_posts is not working in category.php. Instead of quering the posts of the clicked category it fetches all posts of the blog.

    Second, I founded this code to fecth the 3 las posts without using query_posts in this thread http://wordpress.org/support/topic/155668?replies=5


    <?php $cat = get_the_category(); $cat = $cat[0]; ?>
    <?php
    query_posts(array(
    'cat'=> $cat->cat_ID,
    'showposts'=>'3',
    ) );
    ?>

    However, this code doesn’t work inside the loop and if I put it outside the loop trims to 3 posts both, the first and the second loop.

    And here I am stuck. Can I trim the first loop and offset the second loop without query_posts?

  • The topic ‘Category.php template. 3 excerpted, the rest listed’ is closed to new replies.