• For each of my posts I want to split the categories that the post is filed in, in to 2 lists. One list (2-3 specific categories) will display in the top group before the content and the remaining categories will be displayed after the content. Of the 3 specific categories that will be in the top group there will only be 2 displayed for any post. For example cat1 or cat2 and cat3. I want to keep them linked to the categories as well.

    I have attempted the first part by modifying an answer to someone elses post but it is not working for me. Here is what I have.

    ‘<?php if ( in_category(1) ) {
    echo $cat->cat_name;

    } elseif ( in_category(2) ) {
    echo $cat->cat_name;
    }?>’

    This works rather erratically, for some reason I get one of the other categories returned on some posts.

    Can anyone a) see what I am doing wrong, b)point me in the right direction. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jama

    (@jama)

    The next thing that I will want to do obviously is try and exclude the categories that are contained in the top group from the bottom group. I cannot see a simple way to do this using the category tags as they stand at the moment. Is it possible using the existing tags or do you think I might have to hard code this?

    Start here and if you need more help come back and ask.

    The_Loop
    The_Loop#Exclude_Posts_From_Some_Category
    The_Loop#Multiple_Loops

    Thread Starter jama

    (@jama)

    Thanks for that Michael. I had been through this page over the past couple of night but I can’t see how it will do what I want it to do. I have read through it all again today, it talks of excluding posts based on categories but that is not what I want and I don’t know how it could be adapted. I simply want to have all the categories displayed witn my post but in more than one location and each category displayed only once. Thanks anyway.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Split Categories For A Post Into 2 Lists’ is closed to new replies.