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

@MrMaz

Thank you for the pointers. Like I said, I am trying hard to learn how this stuff actually works so that I can become more self sufficient.

I did change out the valid php from above on my homepage, yet it’s still returning all of the posts.

I think something is wrong with my get_exclude_categories_loop function.

(It’s a mess as I am not exactly sure what the top half of the function is doing. copied it from another theme, and made so many changes throughout the day that I’ve lost track…. grrr

I do know that the information is in the database properly. So at least the user UI is working properly :)

function get_exclude_categories_loop($labelz) {
$labelz = "zoo_cat_box_";
$include = array();
$counter = 0;
$cats = get_categories('hide_empty=0');

foreach ($cats as $cat) {

$counter++;

if ( get_option( $labelz.$cat->cat_ID ) == 'true') {

$excludecats[] = $cat->cat_ID;
}
}
if(!empty($excludecats)){
$excludecats = implode(',',$excludecats);
}
return $excludecats;

}

Is there a way to ‘echo’ out the function so that I can at least see if it’s returning something ‘3,5,7’ etc?

Skip to toolbar