• I spend some time searching and found all kinds of results for showing only a single post or limiting the categories. But I would like to do the following:

    On the index page I would like to see displayed the most recent post per category only. So I am not limiting the number of posts or number of categories, but show one post only for each category. The number of posts will be driven by the number of categories.

    Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I am looking to do the same thing – did you resolve this issue?

    The problem is that the post details and what category a post is in is stored in seperate tables. Therefore, a simple query just can’t be done.

    If you guys REALLY want this, I guess I or someone else could try to throw some code together. It won’t be pretty though.

    Here’s similar solution.
    https://rhymedcode.net/1001-wordpression-loops/grouped-by-category/

    Note that in the example above, you have to create a Loop for each category.

    If you add/remove a category frequently, then you need to develop code that will grab all categories.

    Meh, there’s a much better way to do it. I’ll post some code in a bit.

    I found a similar method to alphaoide’s example:

    https://dev.wp-plugins.org/wiki/ShowCats

    This will show the first post (or however many posts assigned in code) for each category – the categories being in a certain order. This is a good fix for the time being.

    Ultimately it would be nice to show the first post for each category organized by most recent post (not by category).

    For example:

    Category 2
    9/20/05 – 4:35 p.m.

    Category 1
    9/20/05 – 3:50 p.m.

    Category 3
    9/19/05 – 6:05 p.m.

    Viper007Bond, I am interested in seeing your idea.

    Thanks!

    Yeah, I can get the ID of the first post to each category, but I’m having issues getting the last post.

    SELECT * FROM wp_post2cat GROUP BY category_id ORDER BY post_id DESC

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Single Post PER Category on Index’ is closed to new replies.