PHP Variable in Shortcode (4 posts)

  1. dantemonaldo
    Posted 4 years ago #

    I wrote a simpe PHP script and have been trying to return the results in WordPress shortcodes, but I can't seem to get it to work. Here is what I have:

    function securetotal() {
        return $secure_total;
    add_shortcode('secure', 'securetotal');

    $secure_total is the predefined variable that I need to be displayed. I can display simple text instead of the variable, but the variable is not transferring any results. Am I missing something? Any ideas?

    Help is much appreciated.

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    you might need to set the variable to 'global'


  3. dantemonaldo
    Posted 4 years ago #

    Thanks a lot! I knew it was something small that I was missing.

  4. dantemonaldo
    Posted 4 years ago #

    What about having WordPress shortcodes wrapped inside a shortcode?

Topic Closed

This topic has been closed to new replies.

About this Topic