Hi, I am new to the forum but I am an avid fan of ACF.
I just have a little request if this is possible.
My request is about the true/false field type. Can you put an additional feature for this field type where in it has a limitation in a post. For example if I have a top 10 items then I will use this field and if there are already 10 items marked as the top 10, this field will not show anymore.
Hope my request is clear.
Thanks to the Dev Team!
Thanks for the quick reply, I am uploading the image of what my idea is all about.
Thanks for the screenshot. I understand the question now.
This is far to custom to include into the core im afraid. That said, it would be possible for you to write some custom code to do this for you.
I would add a function to the wp_head action which would append some jquery to the page. You could query the DB for the amount of posts with this checkbox value (see docs for querying), then depending on the value, you could generate some jQuery to either remove / hide or disable the checkbox field.
All up, it should only take 30 minutes or so.
Thanks for the suggestion, but I don’t know where to put my queries. I checked on the core->field->true_false codes but I am not certain where to put the conditions.
Could you help me out what files to edit or what folder should I go to? I haven’t tried creating a new field type for acf though.
You don’t need to create a custom field type (did I imply that? I did not mean to).
All you need to do is add some custom script to the admin_head action.
If you are not confident in doing this, I would advise you to contract a freelance developer to add the functionality into your site.
As what you suggested earlier, I gathered up an idea tried to implement my queries in the true_false field and I got carried away that the true_false field is fully modified by me and will not be able to serve its purpose anymore. So I created a custom field type instead 😀 out of it.
This is actually a good experience to me and a new learning for today. I succesfully created a “Top[N] Field Type” as what I called it 😀 and it works perfectly.
Thank you for the advise @elliot, really appreciate it.
You must be logged in to reply to this topic.
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!
© 2019 Advanced Custom Fields. Subscribe