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


Display List of category from multisite in theme option

  • Hi
    I have created ACF theme option page in main site. I have arround 5 multisite created. I want list of all categories from multisite to display in main site theme option.
    For e.g if there are 4 categories in site 1 and 3 categories in site so on… then want to display this all categories in main site theme option and user can select any one categories from dropdown.

  • See

    function acf_load_categor_field_choices( $field ) {
      $args = array('public' => true);
      $sites = wp_get_sites($args);
      foreach ($sites as $site) {
        $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
      } // end foreach site
      return $field;
  • Hi John,
    Thanks for reply, but sorry this is not working… i think you misunderstood my question.

    Basically what i want is..

    I will create a field type of Taxonomy with Taxonomy as category in theme option of ACF. In default function it will show list of current categories. But instead I want to display all categories from multi-sites.

    That means it will show complete list of categories available in all sites.

  • What I did was for a select field. I don’t think you can do this for a taxonomy field. Taxonomy fields are select2 fields populated using AJAX and the way the ACF functions work I don’t think it’s possible to get terms from other blogs in a multisite.

    I’d suggest that you look at the functions in the ACF code to see how the taxonomy fields are populated. in the ACF plugin folder /fields/taxonomy.php

  • ok, is there any other way where i can get this functionality

  • This person has created a multisite relationship field. You might be able to use some of that and some of what’s in the taxonomy field and create you own field type.

  • John,

    Thanks for calling attention to the ACF Relationship Multisite add-on.

    Pre v5.0, we were successfully using a Multisite Taxonomy field. I can’t get it to work with 5+ though.

  • And as a heads-up to anyone who comes across this thread, the relationship multisite field add-on project is now dead.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.