[Resolved] Need to limit the number of digits output from a calculation
This support ticket is created 9 years, 3 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Everything works but now I need to limit the number of characters in the output (I really only want the final calculation to show up as something like 17.16%, but it's currently showing up as 17.157712305026%).
I've searched the forum for a solution but have come up empty-handed so far (I've given [trim length=][/trim] as well as length="" to no avail.).
I'm guessing that it may require a modification to the code added to the functions.php file but don't know what that might be (or even if that's the answer).
I added the snippet you provided to my functions.php file, updated it, refreshed one of the pages in question, and the site went blank on the front end.
I realized that I probably wasn't supposed to have both snippets of code in the functions.php file, so I deleted the original snippet (left the snippet you provided above), updated, refreshed, and the calculation was missing (no numbers, just the % sign).
So I decided to start again, with the original snippet, and then see if I could "stitch" a working solution together out of the original snippet and the snippet you provided.
So I replaced the snippet you provided with the original snippet, updated, refreshed, and got the following error message:
So I've got 2 problems. First, of course, is that the calculation is returning a parse error. And, second, after getting the first issue sorted, I'm not sure how to apply the snippet you provided.
Would you mind letting me know what I'm getting wrong / missing?
Disregard my follow up comments. Chrome was causing problems, so I cleared the cache, shut down, rebooted, used the snippet you provided, and everything is working as it should.