I have a wp query loop. I want to check if the post belongs to some categories. I can get the category using the_category()
. I have tried
if(the_category()==`car`){do somthing}
and how to push all the remaining posts except the car category after to all the ‘car’ category.
the_category()
returns many categories.You might want to try get the category
You can run two queries here. The first query gets all posts from the car caregory. The second query gets all other posts except posts from the
car
category. Just remember to changeCATID FOR CAR
with the id of the car category, and don’t forget the minus sign before the ID in the second query. The minus sign means exclude.You can read more on this in the codex:
WP_Query