Home › Forums › Bug Reports › Default value for non-applicable posts
I think this one is somewhere between a bug and a feature request 🙂 Right now if you set a field which has a default value and is only shown for posts in category A and you try to retrieve the value for a post in Category B it gives you the default value. I believe it should give you an empty value since the field is not applicable to that post.
Did that make any sense?
Daniel
I think you have stumbles across what looks like a bug, but what is actually correct behavior. The API functions get_field and the_field, will never return the ‘default’ value on the front end, only the value saved to the DB
If the API is returning the default value, then it must be saved in the DB to that post. Perhaps you first saved the post as Category A, then changed it to B and this left the origional value saved int he DB?
Thanks
E
Hi Elliot,
This is definitely a possibility! I will investigate and get back to you here with an answer,
Daniel
Hi Elliot,
I had a look and I think this is still a bug, I’ve created a hand screencast to explain. Sorry for the weird resolution 🙂
Daniel
Thanks for the simple and easy to understand screencast. I’ll have to do some testing with this one and get back to you.
Cheers
E
Hi Elliot,
It was no problem at all! We can of course fix this on our end by adding some code just before we output the meta but it would be nice if the ACF core took care of it.
As a quick aside, I sent you a screencast about translation stuff a few days ago. On our end this is much more pressing, did you have some time to take a look at it? I think we found a better solution to translate user input 🙂 We actually have a solution, not just a problem 😉
Daniel
The topic ‘Default value for non-applicable posts’ 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.