Category.php template. 3 excerpted, the rest listed (1 post)

  1. ganzua
    Posted 7 years ago #


    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]; ?>
    'cat'=> $cat->cat_ID,
    ) );

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.