Split Categories For A Post Into 2 Lists
-
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.
The topic ‘Split Categories For A Post Into 2 Lists’ is closed to new replies.