Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ):
        ?>
share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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);
share|improve this answer
    
thank You very much @Stephen Harris You rock :) –  jimilesku Mar 6 '12 at 23:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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