Support

Account

Home Forums General Issues Multi Select – Get all choices for Query Args Reply To: Multi Select – Get all choices for Query Args

  • $event_categories = get_field('event_categories');
    var_dump($event_categories);

    gives us

    array(2) { [0]=> object(WP_Term)#4557 (11) { [“term_id”]=> int(179) [“name”]=> string(7) “Virtual” [“slug”]=> string(7) “virtual” [“term_group”]=> int(0) [“term_taxonomy_id”]=> int(179) [“taxonomy”]=> string(14) “event_category” [“description”]=> string(0) “” [“parent”]=> int(0) [“count”]=> int(3) [“filter”]=> string(3) “raw” [“meta”]=> array(0) { } } [1]=> object(WP_Term)#4445 (11) { [“term_id”]=> int(180) [“name”]=> string(5) “Local” [“slug”]=> string(5) “local” [“term_group”]=> int(0) [“term_taxonomy_id”]=> int(180) [“taxonomy”]=> string(14) “event_category” [“description”]=> string(0) “” [“parent”]=> int(0) [“count”]=> int(1) [“filter”]=> string(3) “raw” [“meta”]=> array(0) { } } }

    and

    array(1) { [0]=> object(WP_Term)#4581 (11) { [“term_id”]=> int(180) [“name”]=> string(5) “Local” [“slug”]=> string(5) “local” [“term_group”]=> int(0) [“term_taxonomy_id”]=> int(180) [“taxonomy”]=> string(14) “event_category” [“description”]=> string(0) “” [“parent”]=> int(0) [“count”]=> int(1) [“filter”]=> string(3) “raw” [“meta”]=> array(0) { } } }

    with two categories chosen and three for number of events.

    So as these are two arrays with arrays we get

    NULL
    Warning: foreach() argument must be of type array|object, null given in /Users/jasper/code/site/wp-includes/class-wp-list-util.php on line 164