Categories array
-
I have the following code which test categories and display if they have posts with some metadata set or not.
<?php $category_counter = count(get_the_category()); $counter = 0; foreach((get_the_category()) as $cat) { $counter++; $category_variable = $cat->cat_ID; $query_paying_companies = 'cat=' . $category_variable. '&meta_key=field-company-type&meta_value=j'; query_posts($query_paying_companies); ?> <?php if ( have_posts() ) :?> <p><?php echo $category_variable;?> - This category is good!</p> <?php else: ?> <p><?php echo $category_variable;?> - This category is NOT good!</p> <?php endif; ?> <?php wp_reset_query(); } ?>
Code works well. What I want – and I do not succeed to complete – is to create and array of “GOOD categories” – only the categories with posts which have this metadata set and then random choose one.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Categories array’ is closed to new replies.