Home Forums ACF PRO Calculations



  • How do I make a field with a calculation code? JS or PHP. for example

    Field A = 2
    Field B = 3
    Field C = (formula filed A + field B) = 5 (and this data was inserted into the field)

  • You need to add your own custom JavaScript to the ACF admin create the code that watches for changes in the first 2 fields, does the calculation and then updates the 3rd field.

    How this code is built depends on what version of ACF you are using. However, the JavaScript in ACF4 and ACF5 are not compatible and ACF5 will be released to the WP plugin repo before the end of this year. If you build it using ACF4 then you’ll need to rebuild it for ACF5. I’d suggest buying 5 or waiting until the free version of ACF5 is released to WP.

    For ACF 5 I have created several examples of getting and setting values in ACF using JavaScript. Simple number and text type fields are far easier than many of the examples I’ve created, but the principle is the same.

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

You must be logged in to reply to this topic.