exclude category from WordPress Form function

What about using the exclude array key in your get_categories() call?

e.g. change this:

$massive_categories_obj = get_categories('hide_empty=0');

to this:

$massive_categories_obj = get_categories('hide_empty=0&exclude=14');

Note that exclude expects a comma-separated string as a value.

For your second function, what are you passing as $exclude?

function retrieve_cat_data_sp( $exclude ){
    $args = array(
        'hide_empty' => '0',
        'exclude' => $exclude
    );
    $massive_categories_obj = get_categories($args);

Are you passing a comma-separated string, an array, or something else?

What do you get from this get_categories( $args ) call? Try a var_dump( $massive_categories_obj ) to see what it’s returning?

Leave a Comment