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');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.