• Resolved WordPress User

    (@aumx)


    I am wondering if there is a way to take content between shortcodes and input it into a string, for example, I want to be able to have [shortcode]Hello World![/shortcode] input to a string called $ShortCodeText, how do I do this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • jon

    (@adiant)

    This is the official documentation:
    http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes

    Hope that helps.

    Thread Starter WordPress User

    (@aumx)

    Thank you for your response, I was unable to find how to take the content and input it into a string, do you know how to do this?

    jon

    (@adiant)

    The example puts the value in a string variable called $content. You could do whatever you want with it inside the shortcode’s Function, caption_shortcode in this example.

    If you want access to a string variable outside that function, add

    global $aumx_shortcodetext;
    $aumx_shortcodetext = $content;

    into the shortcode’s Function. And add the same global statement to whatever code you want to use with the value.

    Thread Starter WordPress User

    (@aumx)

    Took me a minute but I got it, thanks for your help!

    Thread Starter WordPress User

    (@aumx)

    One more quick question, what is $atts?
    function content_set1( $atts, $caption = null ) {
    }

    jon

    (@adiant)

    $atts would be an empty string in your case. Otherwise, they are used to store the parameters in a shortcode call, such as [mytable cols=”3″] where cols would be the parameter.

    Thread Starter WordPress User

    (@aumx)

    ok, thank you for your help!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Content between shortcode to string’ is closed to new replies.