Home › Forums › ACF PRO › How to update the db with a default value › Reply To: How to update the db with a default value
In most cases it would be much easier to alter the code in your template to check for a value an if it does not exist then show the default.
$value = get_field('my_field');
if ($value === false) {
$value = 'default_value';
}
To do it the other way, you can:
I generally do the former and code my templates to deal with default values because I assume that any field might be empty.
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.