Title: Content between shortcode to string
Last modified: August 21, 2016

---

# Content between shortcode to string

 *  Resolved [WordPress User](https://wordpress.org/support/users/aumx/)
 * (@aumx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/)
 * 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](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021461)
 * This is the official documentation:
    [http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes](http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes)
 * Hope that helps.
 *  Thread Starter [WordPress User](https://wordpress.org/support/users/aumx/)
 * (@aumx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021464)
 * 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](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021526)
 * 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](https://wordpress.org/support/users/aumx/)
 * (@aumx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021531)
 * Took me a minute but I got it, thanks for your help!
 *  Thread Starter [WordPress User](https://wordpress.org/support/users/aumx/)
 * (@aumx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021533)
 * One more quick question, what is $atts?
    function content_set1( $atts, $caption
   = null ) { }
 *  [jon](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021534)
 * $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](https://wordpress.org/support/users/aumx/)
 * (@aumx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021570)
 * 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.

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [WordPress User](https://wordpress.org/support/users/aumx/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/content-between-shortcode-to-string/#post-5021570)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
