So are you executing this code when someone clicks on a category and not a single post?
yes, i acctually have two columns (loops) with posts, the left one displays of instance posts with category id’s 1, 2, 3, the right displays 4, 5 and 6
but when someone clicks on a category, they are displayed in the left column (loop) so i then want to prevent them from displaying in the right also.
I’m confused. You say ‘when they click on a category, they are displayed in the left column’ – what are you talking about? Posts from that category? Do you have a link that you can share that shows what you are doing?
I can’t because it’s a password protected site at the moment.
I mean if someone wants to see al the posts for instance from category 6 ,these posts are normaly displayed in the right column but now the category displays them aswell in the left column and i don’t want that.
like this:
left – right
1,2,3 – 4,5,6
someone clicks 6 and it’s like this:
6 – 4,5,6
but i want:
6 – 4,5 (and not 6)
I hope this is understandable, sorry i can’t send a link…
What about using is_category http://codex.wordpress.org/Function_Reference/is_category
and they do something like:
if (is_category( 'catName or id' )){
$cur_cat_id = id of that Category;
}
and so forth so $cur_cat_id gets the id of each category id by using conditional statements.
Yes, I solved it like this:
before the loop I check the current category
<?php $category = get_the_category(); ?>
Then in the loop I check if it’s a category page, if so, if the post is the same category as the current one i continue
<?php if (is_category()) {
if (in_category( $category[0]->cat_name )) { continue; }} ?>
thanks