• Resolved matt-tyas

    (@matt-tyas)


    Hi and thanks in advance for any help.

    I am running this basic query in my loop file to output one post from each category and sub-category:

    Code in pastebin: http://pastebin.com/srwgpWN6

    And so on for about 20 categories.

    The issue is the posts are sometimes in multiple categories and this is causing duplicates on the homepage. What can I add to stop this duplication?

    Thanks again.

    Matt

Viewing 5 replies - 1 through 5 (of 5 total)
  • the method to avoid duplicate posts in multiple looops is described here (the ‘array’ method after the ‘Note for Multiple Posts in the First Category’ headline): http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

    do you have the code to show all your categories with one post?

    Thread Starter matt-tyas

    (@matt-tyas)

    Hi,

    That is the page I was (trying) to follow instructions on by using:

    $do_not_duplicate = $post->ID;

    I understand I am probably using it incorrectly as I am not much good at PHP. I want to show the latest post from each category and sub category. As you can see currently on my homepage – http://www.manchesterfinest.com there are a lot of duplicates. I am trying to eradicate these. So if a post has already been displayed then it appears in another category, it will be skipped over and the next newest will be shown.

    I hope that makes sense.

    A longer pastebin is here: http://pastebin.com/KeiYZWm2

    Thank you

    I particularly pointed to the ‘array method’ – have you read the linked codex chapter and tried to implement it?

    here is a partly corrected section of your code, to show the principle:
    http://pastebin.com/hv0vjzye

    Thread Starter matt-tyas

    (@matt-tyas)

    Thank you I will give this a go and get back to you, with good or not as good news.

    Thread Starter matt-tyas

    (@matt-tyas)

    Hi, it looks like that has worked for me, many thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to output one post from each category need to avoid duplicates’ is closed to new replies.