Skip Navigation

[Resolved] How to Multiply Post Count with a Number and Display using View

This support ticket is created 2 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by manishB-2 2 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#2066355

Hi Support team
I am trying to multiply the total post count of a user and multiply it with a number for example 20.

I basically found a Function in one of the Forum posts and it works but it breaks my site in the frontend.
https://toolset.com/forums/topic/calculator/

add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);
$content = eval("return $content;");
return round($content);
}

It works perfectly but there is the only issue that it breaks my frontend and I can only see a white screen. So maybe it is creating any conflict.

So Please let me know how I can make it work.
Below is the line on View that I am trying to display

[wpv-calculate]€ [wpv-found-count]*20 [/wpv-calculate]

Waiting to hear from you soon.

#2066631

Its an urgent issue, So Please someone help me.

#2066859

Hello, that snippet doesn't seem to work for me either. It's about 9 years old, so it could be a problem where PHP syntax has changed since then. I would try moving the euro symbol outside of the shortcode first. If that doesn't help, you might need to write a new custom code solution, since Views isn't really designed to calculate values like this. If you're seeing a white screen, you might be able to diagnose the problem by turning on server logs.

Go in your wp-config.php file and look for

define('WP_DEBUG', false);

Change it to:

define('WP_DEBUG', true);

Then add these lines, just after the WP_DEBUG line:

define('WP_DEBUG_LOG', dirname(__FILE__) . '/error_log.txt');
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define('WP_DISABLE_FATAL_ERROR_HANDLER',true);

Test the page again. If any server-side errors are triggered during this process, it will create an error_log.txt file in your site's root directory. Use FTP to look for this file in the same directory as wp-config.php. You may need to click "Refresh" in your FTP browser to see a new file appear. Once that is done, you can revert the changes you made to wp-config.php and delete the log file using FTP.

#2067137

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.