Home › Forums › General Issues › Values for select field lost › Reply To: Values for select field lost
Hi @Stavros
I would like to clarify some things about the default value of a field, because I believe you do not have any bugs, but just some logic issues with your code.
A default value is only loaded when creating a new post. If that value is not saved (hidden by conditional logic), the the_field function will not return anything into your theme.
If you were to save the value (turning off conditional logic), the default value would correctly POST to the save function and the value would be saved to the DB. The the_field function will not display the value.
If you were to now add in the conditional logic to hide this field in the back end, the value will never be ‘deleted’ from the post and will still remain in the DB. This mean the the_field function will display the value which is hidden in the wp-admin.
I think you need to take this into consideration with your code and add in some conditional statements that check if the ‘select’ field is ‘a’ or ‘b’.
I hope that helps.
Thanks
E
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.