Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;

    print_r($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 at 14:10
    
Fixed that error in the op. Was still not generating the list of categories. –  Picard102 Jun 6 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 at 14:27

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.