Home › Forums › Add-ons › Options Page › Default values not loading on Options page
(Somehow I didn’t notice there was a new forum last week, and I managed to post this to the old one. Here’s what I had posted there.)
Hello,
I have 2 options pages set up, and several field groups that appear on them.
I have set default values for most of the fields, but they do not appear. No radio buttons are selected, no text shows in the text fields, no numbers in the number fields, etc.
If I set those same field groups to appear on a write panel for any post type, the default values do appear. It’s only the Options pages that they aren’t working on.
Is anyone else experiencing this, and any ideas on how to fix it?
Oops, never mind. When I’d originally posted this a few days ago in the old forum, I had the latest version of ACF. I just noticed after reposting here that a newer version was available. I updated, and that fixed the problem.
Ok, this problem has returned with the two latest updates. It feels like it’s probably a JavaScript problem, and I’m guessing it’s something on my end since I haven’t seen anyone else post about it.
I have already tried removing all JavaScript from my theme, but that didn’t seem to have any effect.
I’m not getting any errors, so I’m not sure what to try next.
Any suggestions?
(Also, is there a way to remove the “solved” status of a thread? I didn’t think I should create a separate post for this, since I’d already described the problem once before, but it is no longer “solved” for me.)
Hi @AmandaB
If you have already saved a value on the options page, the default value will not be loaded. Is there already a value in the database for that field?? Even a blank value (null / false / empty)
Hi Elliot,
This is on a brand new site, immediately after the WordPress install. I just searched the database for one of the field names, but nothing was found.
I also have fallbacks in place for if a value doesn’t exist, and the theme is currently outputting those fallbacks.
Hi @AmandaB
I’m not sure why this is not working for you. I just created a new field called ‘Test New Field’ (text) and added it to the options page via the location rules.
This field had a default value of ‘Test default’
I opened the options page and the default value ‘Test default’ loaded into the input.
I then saved the field and it saved with the default value correctly.
Looking at my wp_options table, I noticed that the option_name is actually ‘options_test_new_field’, so the options page add-on saves with a prefix of ‘options_’.
Perhaps this explains why you could not find a value previously.
Looks like it’s working correctly for me, hope you can get it to work.
Cheers
E
Hi Elliot,
i do this with the colorpicker.
The default value has been stored in the database.
But if I clear or change the value the default value is ignored.
I wish that the default value is displayed as a color after I pressed on clear button.
Isn’t it possible?
Cheers
Roman
Hi @breiter
A default value is only loaded when a value does NOT EXIST in the DB. What you have described is clearing the value, or selecting #fff. This is still a value and still EXISTS in the DB. THerefore the default value will not load.
The actually row in the DB must be completely removed from the DB for ACF to load in the default value.
If you require customization to this, please read the docs for the ‘acf/load_value’ filter
Thanks
E
The topic ‘Default values not loading on Options page’ is closed to new replies.
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.