0

My question:

This code retrieves the categories. I need to exclude the category number:81. Is there an easy way to exclude it in this code?

<?php   
            $cat_lists = retrieve_cat_data_sp( get_option('bn_exclude_home_lists') );

            for ($i = 1; $i < count($cat_lists); $i++ ) {

            if( (get_category( $cat_lists[$i] )->count) > 0 ):
        ?>
  • can you paste the code from your options page that calles the category list into your options page? there is the best place to clean it even before loading the categories into a list.. – Sagive SEO Mar 6 '12 at 20:42
1

If retrieve_cat_data_sp is the function from this question then that returns categories except the ones given in the argument:

$cat_lists = retrieve_cat_data_sp('81');

It essentially a wrapper for get_categories. So to exclude multiple Ids

$cat_lists = retrieve_cat_data_sp('81,82');

If you want to exclude 81 as well as those IDs listed in get_option('bn_exclude_home_lists') then, assuming that option returns something in the form of comma separated IDs '12,13,36':

$exclude = (get_option('bn_exclude_home_lists') ? get_option('bn_exclude_home_lists'):'');
$exclude .=',81';
$cat_lists = retrieve_cat_data_sp($exclude);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.