Addition (can’t edit):
If you’re using ACF Blocks, you’ll need this snippet
function fix_post_id_on_preview($null, $post_id) {
if ( is_preview() && $post_id !== 'options' && substr( $null, 0, 6 ) != 'block_' ) {
return get_the_ID();
}
else {
$acf_post_id = isset($post_id->ID) ? $post_id->ID : $post_id;
if (!empty($acf_post_id)) {
return $acf_post_id;
}
else {
return $null;
}
}
}
add_filter( 'acf/pre_load_post_id', 'fix_post_id_on_preview', 10, 2 );
In case you stumble upon the aforementioned solution at https://support.advancedcustomfields.com/forums/topic/preview-solution/page/3/#post-136816 and need to fix your options fields this slightly modified snippet worked for me:
function fix_post_id_on_preview($null, $post_id) {
if (is_preview() && $post_id !== 'options') {
return get_the_ID();
}
else {
$acf_post_id = isset($post_id->ID) ? $post_id->ID : $post_id;
if (!empty($acf_post_id)) {
return $acf_post_id;
}
else {
return $null;
}
}
}
add_filter( 'acf/pre_load_post_id', 'fix_post_id_on_preview', 10, 2 );
Obviously works only if you’re using ‘options‘ in your get_field calls, not the singular ‘option’.
I had the same problem, the reason was wrong owner / group settings for the folder.
If you find that chmod 777 would work, changing to the right chown owner:group, chmod 755 will do fine again.
Thanks Elliot and John, for being so quick addressing this!
The updated version 5.3.9.1 works both fine with string and object in my case.
Thanks John, this fixed my issue.
However, for the record, it is mentioned here in the documentation Get values from a taxonomy term (scroll to “Finding the active taxonomy & term on an archive page”) that you can use the object on archive page.
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 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.