0
votes

I want to get the content of the custom post type "team" from every blog of a multisite. I managed to get the post title and thumbnail but I can't get the values of the custom fields made with acf. I get the values of the custom fields only on the current blog. This is the code that I have right now:

                global $switched;
                $sites = wp_get_sites();

                foreach ( $sites as $site ) : setup_postdata($post); 
                    switch_to_blog( $site[ 'blog_id' ] );
                    $args = array(
                'posts_per_page' => -1, 
                'post_type' => 'team'
                );

                query_posts($args);
                if (have_posts()) : while (have_posts()) : the_post(); ?>
                 <?php  
                $post_id = get_the_ID();
                 ?>
                    <li class="col-xs-12 col-sm-4 col-md-3">
                        <div class="round-clip">
                            <img src="<?php the_post_thumbnail_url('full'); ?>" alt="team">
                        </div>
                        <div class="colleague-details">
                            <span><?php the_title(); ?></span>
                            <p><?php echo get_post_meta($post_id, 'member_title', true); ?></p>
                            <p><?php the_field('member_phone_number'); ?></p>
                            <a href="mailto:<?php the_field('member_email'); ?>"><?php the_field('member_email'); ?></a>
                        </div>
                    </li>

                <?php endwhile; endif; wp_reset_query();
                switch_to_blog( $current_site );
                $GLOBALS['_wp_switched_stack'] = array();
                $GLOBALS['switched']           = FALSE; 
                endforeach ; 
                ?>

Thank you!

1
Forgot to mention that I used get_post_meta, as well as the_field... Both work only for the current blog. - Catalin Adrian Ioana
For anyone looking for this: the above code was correct only the name of the fields on the other blogs were slightly different. Just have the same name of the field and the above code will do the trick - Catalin Adrian Ioana

1 Answers

0
votes

I would try this, since you have the id already,

`<?php the_field('member_phone_number', $post_id); ?>`

But not sure if it would work