Support » Plugins and Hacks » Multiple Latest Posts – Categories

Multiple Latest Posts – Categories

  • Hey Community,

    Is it possible to include a list of the latest posts from a category on another category page, i.e., a list of the latest posts from Category-B on the Category-C page?

    I was searching around for a plugin and etc., but I could use some help.


Viewing 7 replies - 1 through 7 (of 7 total)
  • I found this discussion on the forums:

    Looks like it would of worked great, but when I enter in the code it only seems to repeat the posts from the category page, instead of listing the posts from a specific category. I will keep looking into this, if anyone has an idea, your thoughts would be greatly appreciated.

    That’s exactly what Kaf was warning about on that page…

    Ah Ha! I found a solution that wasn’t working for someone else but it works for me!

     $myposts = get_posts('numberposts=5&offset=1&category=1');
     foreach($myposts as $post) :
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> --- <?php the_excerpt(); ?></li>
     <?php endforeach; ?>


    I thought I found a solution. This is working fairly buggy. It isn’t pulling the correct number of posts, and some categories aren’t working… so still searching.

    OK, I found the solution. I was doing test posts with categories that had only one post in them. By taking away “offset=1” everything works fine. So the solution is:

    $myposts = get_posts('numberposts=2&&category=1');
     foreach($myposts as $post) :
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> --- <?php the_excerpt_reloaded(15, '', 'none', TRUE, '', FALSE, 2); ?></li>
     <?php endfor

    Now I have an additional question. I have some sub categories, and I noticed that this function doesn’t seem to include the posts of those sub-categories when selecting a parent id, e.g., category 1 is the parent to categories 3 & 4, and when I enter category “1” into the code above, I am not given the posts from categories 3 & 4… like a category page works. Instead I am given only those that are specifically filed under category 1. Any idea on how we can modify the code to work accordingly?


    Hey Moshu,

    Good to hear from you… it’s been a while. I skipped past your post when I found something that started working, sorry about that.

    I thought I made tweeks, in accordance to what Kaf mentioned, but for some reason it wasn’t working. It must of been human error somewhere on my part.

    Any idea on a category solution to what I mentioned above?


    As it is widely known, I am not a coder, so I wouldn’t be able to tweak the code you’ve found.
    However, I know that type of queries don’t really care about parent-children relationship: they “understand” only what you put explicitely there, i.e. the cat ID#.
    You could, probably, hardcode the children cats too into the query, just don’t ask me how.
    Even smarter coders might have a solution for for the inclusion of the children cats

    Now I too widely know 🙂

    Great feedback, thank you.

    A work around is to select both the subcategory and it’s parent when posting.

    Thanks again Moshu, you have helped me many times.


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Multiple Latest Posts – Categories’ is closed to new replies.