Support

Account

Home Forums General Issues Output taxonomy array as comma-separated integers for query

Helping

Output taxonomy array as comma-separated integers for query

  • I am completely stumped and wanted to reach out to see if anyone can point me in the right direction.

    I am using a Taxonomy field on an options page (set to return Term ID) to select categories on which content from a text field will appear. I wanted them to be able to choose more than one category, and return those values as a comma-separated integer array.

    Using this

    $show_post_footer_categories = get_field('show_post_footer_categories','blog-settings');
    print_r($show_post_footer_categories);
    

    I was able to get this:
    Array ( [0] => 3 [1] => 5 [2] => 9 )

    But I need it to return something like this…

    3,5,9

    For this…

    if(in_category('3,5,9'))

    Anyone able to help out a very tired front-end developer?

  • 
    echo implode(', ', $show_post_footer_categories);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.