Get field value of sub site in wordpress by ACF

We have a WordPress website which has 10 sub sites(blogs) . We show the latest post of those sub sites on the main site . Recently we added and use Advanced Custom Field which is active now on the main site and all those 10 sub sites and in each one we sat just a true/false field and its name is : is_announce .
In each site ( main or sub sites ) we have access to that field by get_field and it works great .
The problem is , on the main site we have no access to those fields of sub sites.It seems get_field works good just for each site’s scope ( main or sub sites )

How can we fix it ?

Read More

Addition : As i told you we show the latest post of each sub website . each one has been featured by one custom field (is_announce) . We want to read its value and if it is True , show something on the top of each post , something like tag .

Related posts

1 comment

  1. Based on RST’s comment , i could solve my problem :

                    <?php
    
                            $slug = $post->blogname;
                            $blog_id = get_id_from_blogname($slug);
    
                            switch_to_blog($blog_id);
    
                            if( get_field('is_announce') )
                            {
                                echo "<div class='announce-container'>ANNOUNCE</div>";
                            }
    
                            restore_current_blog();
    
                    ?>
    

Comments are closed.