Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
3.1.8 broke get_fields for options
-
Just updated to ACF 3.1.8, and get_fields( 'options' ) no longer works for the options page add-on. Looking at api.php, it seems that the options add-on was forgotten when the options were moved from wp_postmeta to wp_options in the db. The function just returns false if you pass it 'options' as the argument so there is no way to pull all of the values of the options page at once.
Hoping this can get fixed soon! -
Can this be fixed? Have upgraded a few clients' sites where I had used this and had to rewrite some of the code to pull in each one individually.
-
Please update ACF.
-
I'm already using ACF 3.3.6, and get_fields() still has no support for 'options'. It has been missing since 3.1.8, which is why it has been breaking when I have been upgrading sites from anything pre 3.1.8 to anything after.
-
Still broken in 3.3.9 - is there any reason this bug isn't on the to-do list? Or are you dropping support for this function (I notice it's not really in the docs anymore).
-
Hi TripleM,
Yes, your right. I'm not sure why I had forgotten, but I had. I'll add in the $post_id param to that function.
I'll create the doc for it too
Cheeres -
Hi guys,
Sorry. I misunderstood the original question. The get_fields function can only work for posts / pages due to this reason:
- the function uses a $post_id to look for all custom field data in the postmeta table. It then returns all the values as an array. Some of these values may not hav anything to do with ACF. It is a very basic function that does not query ACF to find the exact ACF fields for that post
if this method was to be used with the wp_options table, it would return every single option saved in the wordpress site. About 1% of the returned values would be ACF fields, the rest would be other plugin data.
Sorry, but this function cannot be used with the options page at the moment.
In the future I would like to use the location rules to match field groups on the front end, but this is not possible at the moment.
Thanks
Elliot -
Hi Elliot,
Yes, I know that's why it broke but it's easy to fix; you don't need to fetch the entire options table - just select rows which have a key starting with "options_". -
Hi TripleM,
That's true, The sql would be quite simple actually ( why didn't I think of that... )
I'll add it in the next version
Cheers
Elliot