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( ) );
  • 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. – Nicolai 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. – Nicolai Jun 6 '14 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.