Support

Account

Home Forums Feature Requests Sync custom fields with custom filter

Solving

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

    • Get all the posts
    • Check the value of the field in each post
    • Alter the values (or not) in all of the posts based on the value submitted by for the current post

    For more information on acf/save_post http://www.advancedcustomfields.com/resources/acfsave_post/

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Sync custom fields with custom filter’ is closed to new replies.