Support

Account

Home Forums ACF PRO switch_to_blog() breaks get_field(), the_field(), get_post_meta() etc. Reply To: switch_to_blog() breaks get_field(), the_field(), get_post_meta() etc.

  • I honestly don’t know what the problem could be and without setting up a site that does the same thing that yours does there’s no way I can debug it.

    Are you altering anything in the global $post? for example, are you running any loops that call the_post()? ACF uses the value in $post->ID to get values. If this is being alter, it could be the source of the problem.

    Another issue could be the post meta cache. If the post ID of the post on the other site is the same as the post ID of the post on the current site then WP itself could be getting the wrong values because it’s getting the values stored in the cache instead of getting the values from the database. If this is a possibility, you might want to clear the post meta cache before switching back to the current blog wp_cache_delete($post_id, 'post_meta');