Hey guys,
I'm sure I'll work this out myself in the next few hours, but in my search results page I need to decipher whether the output loop contains just pages, just posts, or a mixture of both; and chuck out a suitable class to style off.
I'm guessing category is quite important here..?
Any help much appreciated - even some pseudo code would be awesome.
Thanks!
L
Well, I have this and it works. Would love some more intelligent input though :]
<?php $category = get_the_category();
// cat_ID 5, 6, and 7 are the only existing post categories presently
if ($category[0]->cat_ID == 5 || $category[0]->cat_ID == 6 || $category[0]->cat_ID == 7){
echo 'post';} else{
// everything else is a page (because it doesn't have a category)
echo 'page';
}
// this method isn't very scalable is it :[ (e.g. if someone adds a new post category i'll have to update the if condition) ?>
Thanks,
L
tamilsweet
Member
Posted 2 years ago #
Can't you use
is_page() function !?
The search results page is a page every time, regardless of what's pumped out in the search ;]
L