WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

            $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
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

Your Answer


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.