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

I'm trying to pass a list of all the categories to my MixItUp settings in my JS file to show all the items on load. But I can't seem to generate a list of the categories and reliably send them over to the JS file.

Here're how I've been trying to generate the categories.

function cats()
    $args = array(
        'taxonomy' => 'portfolio_categories',
        'orderby' => 'name',
        'order' => 'ASC'
    $categories = get_categories($args); 

    $slugs = array();
    foreach($categories as $category) 
        $slugs[] = $category->slug;

    return $slugs;


And once that works I figure I would need to send it via ?

wp_localize_script('main', 'cats', array( ) );
share|improve this question
Change $$args to $args. And, $images[] to $slugs[] or vice versa. Regarding the use of wp_localize_script see the documentation and search the site, I'm certain you'll find what you need. – ialocin Jun 6 '14 at 14:10
Fixed that error in the op. Was still not generating the list of categories. – Picard102 Jun 6 '14 at 14:13
Only thing I can say is, what you doing isn't wrong per se, so go on debug your steps. – ialocin Jun 6 '14 at 14:27

Your Answer


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

Browse other questions tagged or ask your own question.