• Hi.

    Does anybody know,how can i make my blog do,that on the home page it wont display all of the posts from every category,but only 1 of each category’s recent post??

    thank your very much for the answer!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • https://pastebin.com/64FZhQU0

    probably need to create a home.php based on index.php and the above code.

    EDIT: typing error in line 7:
    should read:
    'category__in' => $cat->term_id

    Thread Starter never_stop

    (@never_stop)

    thanks for the advice,but i tried already this way,and maybe because im stupid or something,i cant make it work!
    I thought about,what if tha sidebar widget displays the the last 5recent post,and i write that in to the index.php…can it work somehow?

    Hi never_stop, I’m looking for the same code with no success either…

    alchymyth, the code on the page you provide doesn’t work for me. I get the name of each category but the excerpt is always the same one from the latest post from the first category…

    I of course checked the Codex but I didn’t find anything about getting the last post from each category.

    Any idea how we could do that? Thanks! ??

    @alkorr
    thanks for the error description;

    typing mistake:

    correction:

    'category__in' => $cat->term_id

    Hi alchymyth, thanks a lot! ??

    Now I try to display the categories not in alphabetical order but showing first the categories recently updated. As of now, my first alphabetical category has the oldest published post so it’s not very appealing for my reader. I tried to use orderby=date but then nothing is showing anymore.

    I also tried to exclude a category from the list using ‘category__not_in’ => -34, but it didn’t change anything, the category I want to exclude is still showing… Maybe you have an idea why it’s not working?

    Thanks a lot for your help alchymyth! ??

    das excluding has to be done in the first line:

    <?php  $cats = get_categories('orderby=count&order=DESC');

    https://codex.www.ads-software.com/Function_Reference/get_categories

    as for sorting, categories are not really updated; i know what you mean – the category with the post that got most recently updated.

    i don’t think there is a direct connection between the category tables and the modified date of the post table in the database.
    and i am no expert in direct database queries.

    Ok alchymyth, I will try that.

    Thanks again! ??

    Ok. Now I’m using the code provided by MichaelH on this thread. Thanks to you alchymyth there no more duplicated posts in the list but I’m still trying to display the categories not in alphabetical order but showing first the categories recently updated. And also to exclude a category from the list.

    Still looking for a way to achieve that, I’m reading the Codex (again).

    Meanwhile if anoyne has an idea, it’s welcome, thanks! ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Only one posts of each category on the home page’ is closed to new replies.