Loop stuck on get_categories and then foreach
-
I’m using this code to style top level categories that have posts differently from the ones that don’t have posts. But the loop gets stuck now that I have more categories. It worked well with 200 categories, but now I have about 3000 categories and it get stuck on the first one.
Has this to do with php limits or WordPress limits?
$allcats = get_categories('hide_empty=0&exclude=1&orderby=slug&order=ASC'); foreach($allcats as $thecat) { $test=get_posts('category='.$thecat->cat_ID); if ($thecat->parent < 1) { if ($test) { echo "<li><a href=\"" . get_category_link($thecat->cat_ID) . "\"><span>". get_cat_name($thecat->cat_ID) ."</span></a></li>"; } else { echo "<li class=\"maincatinactief\"><span>". get_cat_name($thecat->cat_ID) ."</span></li>"; } } }
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Loop stuck on get_categories and then foreach’ is closed to new replies.