Custom shortcode displays at page top. Not where I put it?

I’ve got a custom shortcode:

function get_saturation($atts) {
        $sws = exec("awk -F"," '{if(NR==2) printf("%.1f \n",($10/8.4)*100 )}'          
        data/2myfile.csv", $retval);
    echo   $sws . " percent saturation<br>";
}
add_shortcode('saturation', 'get_saturation');

The short code itself works (surprisingly) but the data is displayed at the page top not where I inserted the shortcode.

I’m thinking I can’t just eco the data here, instead of echo I need add a new variable for the result of $sws . percent saturation.

Something like:

      $atts =  $sws . "percent saturation<br>"; 

But, the above does not work. What am I missing?

Read more here: Custom shortcode displays at page top. Not where I put it?

Leave a Reply

Your email address will not be published. Required fields are marked *