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.
Its an urgent issue, So Please someone help me.
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.
My issue is resolved now. Thank you!