Support

Account

Home Forums ACF PRO Display List of category from multisite in theme option Reply To: Display List of category from multisite in theme option

  • See https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/

    
    function acf_load_categor_field_choices( $field ) {
      $args = array('public' => true);
      $sites = wp_get_sites($args);
      foreach ($sites as $site) {
        switch_to_blog($blog_id);
        $categories = get_categories();
        foreach ($categories as $category) {
          // I'm using both the blog id and the term id for the
          // select value so that you'll know what site to get
          // the category from
          field['choices'][$site['blog_id].'-'.$category->term_id] = $category->term_name;
        } // end foreach category
        restore_current_blog();
      } // end foreach site
      return $field;
    }