I'm wondering how I can add a global variable containing an array of category IDs.

On my site, I have menus and custom loops and every time I want to delete a category of them, I have to access each and add the ID of the category to be deleted.

My idea is to have a variable with these ids.

$excluded = array( 1, 2, 3, 4 );

Can I use the functions.php for this?

1 Answer 1


Simple solution- use GLOBAL variables..

$GLOBALS['my_categories_list'] = array(1,2,3,4);

then you can everywhere access $GLOBALS['my_categories_list'].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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