Skip Navigation

[Resolved] Add 1 onto whatever the value is

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#921385

Hi

Is there a way to whatever is in X field add 1 on to this value. So if the value is 3 we can output on the page 4?

Thanks.

#921568

Hello,

Please elaborate the question with more details:
So if the value is 3 we can output on the page 4?
How do you setup the custom field and field value? What and where do you want to output?
If you want to check the custom field value, and display something, please try the shortcode [wpv-conditional]:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#921754

Sorry I will try to explain with more detail.

Say we have a field called wpcf-amount

This field on a post has a value thats been set of "4" in the field.

What I want do on a view is print on the page this value but +1. So instead of showing 4 on the page it shows the number 5. It always wants to just add 1 to the value of whatever the field is.

Thanks

#922296

There isn't such a built-in feature within Views plugin, but you can try to create some custom codes to do the calculation, for example, this thread:
https://toolset.com/forums/topic/calculator/

#922663

The only issue with this solution is needing to edit functions.php which we can’t do as when the theme updates it’ll wipe out our changes.

Is there any way to avoid this?

#922776

Yes, you can setup the PHP codes with some plugin, for example:
https://wordpress.org/plugins/code-snippets/

Then you will be able to add PHP codes in wordpress admin side without touching your theme files.