Hmm, looks like I overlooked the $field_key notes further down the docs page which explains why using $field_name is not the best choice.
Does/did the page/post exist prior to creating the group and or fields within the group. If the post/page is not saved/updated “after” the field is created it doesn’t exist in the post meta and will return nothing.
Hmmm, looking a bit deeper it might be possible. See https://developer.wordpress.org/themes/advanced-topics/customizer-api/#custom-setting-types
It appears one can use customize_update_$setting->type and customize_preview_$setting->type actions to build a custom setting object that saves/previews data other than theme_mods and wp_options. I haven’t looked to see if customize.php gives us the post object or if we’d have to build a custom query but it looks promising. I’m very surprised there is little mentioned of this on the webz.
This is due to lack of core capability in the wp customizer. To my knowledge, the customizer currently is only built to work with theme options, theme mods (widgets and menus). Hopefully post objects will come.
You might look at this. I haven’t used it but it appears to allow for ACF fields to be added to widgets in which can be manipulated via the customizer. https://gist.github.com/fabrizim/9c0f36365f20705f7f73
+1 on this as well. I’ve been using Kirki and can easily modify anything in $pre_options table like theme/site wide options, custom css but current customizer doesn’t have a post_meta method or even $post object which would be awesome. Maybe we can help nudge them in the right direction?
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.