Home › Forums › General Issues › Default values by option page on first load › Reply To: Default values by option page on first load
You either need to use update_field() to set defaults for every field when the theme is set up https://www.advancedcustomfields.com/resources/update_field/ or check the values and if nothing is returned then assume the default.
$value = get_field('my_options', 'option');
if ($value === NULL) {
$value = 'my-default-value';
}
I prefer the second method.
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.