Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Need some ninja guru help on a function to exclude cats from loop


Anointed
Participant

@anointed

I’ve narrowed down the query_posts function to one that works perfectly when I manually type in the numbers 4,42,46 that makes it so those categories are not showing up in the loop.

This works:

<?php
$excludecatss = get_exclude_categories_loop();
print_r ($excludecatss);
query_posts(array('category__not_in' => array(4,42,46)));
?>

This does not work:

When I don’t hardcode in the numbers and try to use my $excludecatss in there instead, it does not filter the loop like the hardcoded one did.

Tells me this function is not right…

<?php
$excludecatss = get_exclude_categories_loop();
print_r ($excludecatss);
query_posts(array('category__not_in' => array($excludecatss)));
?>

Both of them print out the proper numbers before running the query, so I know my print_r is returning exactly what I want, 4,42,46

Where I am stuck is the query_posts part.

I can’t seem to get that to have $excludecatss put the numbers there so they are excluded….

Skip to toolbar