Home › Forums › Feature Requests › Sync custom fields with custom filter
Hello,
ACF is a super plugin.
I have a question about one of my current project.
I wanted to create a custom fields “rank” which will contain a digital value (ex: $value). I want to use this value to classify/sort articles by its position on a page.
How to create the 3 following functions? :
-need to compare all the field value custom “Rank” with all sections to avoid duplicates.
-compare the values to sort the articles with categories and tags according to its order of rank (descending or ascending)
-If the value exists, shifted all the other value greater than n in n + 1 (ex: If value = 12 and 12 exists for an article, replace value in A 12 + 1, and any other value for n + 1)
Thanks for help
I think you’re asking for too much at one time and I’m not completely sure I understand what you’re looking for and I’m afraid if I did it would take several far too long to explain how to set it up, code it and test it. This forum is mostly users helping other users.
I wanted to create a custom fields “rank” which will contain a digital value (ex: $value).
That’s the easy part.
I want to use this value to classify/sort articles by its position on a page.
Sort them by the position on the page? Do you mean sort the posts by this field?
-need to compare all the field value custom “Rank” with all sections to avoid duplicates.
Sections? What do you mean by sections?
-compare the values to sort the articles with categories and tags according to its order of rank (descending or ascending)
Not sure what you are sorting here or by what.
-If the value exists, shifted all the other value greater than n in n + 1 (ex: If value = 12 and 12 exists for an article, replace value in A 12 + 1, and any other value for n + 1)
?
Thanks for your reply
I simplify my question because I see that it is a little difficult to understand
I have custom field of type digital which is required on each post.
Yes, I mean sort the posts by this field. To do this, I got the answer via documentation.
> How to avoid that this custom field has similar values via the following logic?:
-If in the creation of the post A, the user insert in the custom field a value ‘x’ that already exist on another post B, it removes that value ‘x’ of the B post and replaces it with ‘x + 1’ as well as all other existing values that are greater than ‘x’ in this custom field on each post.
If you want to change the submitted value and also alter values in other posts based on what is submitted you would need to create an acf/save_post function.
In this function you would need to
For more information on acf/save_post http://www.advancedcustomfields.com/resources/acfsave_post/
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.
— Advanced Custom Fields (@wp_acf) February 23, 2023
👉 https://t.co/3UtvQbDwNmhttps://t.co/wfFEVcXVKc
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.