user6176114 user6176114 - 1 year ago 100
PHP Question

How to multiply answer of a shortcode in PHP

I am currently working on my wordpress website and I need to multiply answer of a shortcode by 10. Here's the code I am trying -

$first_number = '[affiliates_hits for="month"]';
$second_number = 10;
$sum_total = $second_number * $first_number;
print ($sum_total);

I am using a plugin called 'affiliates' and the shortcode [affiliates_hits for="month"] shows the number of visits. Currently when I echo [affiliates_hits for="month"], it shows number 8.

So the above code should result in 80, but it results 0.

Answer Source

Have you tried doing a do_shortcode(), since you are trying to hard code this in php.

WordPress Codex Resource:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download