Title: found code to fix shortcode issue, not sure where it goes
Last modified: August 19, 2016

---

# found code to fix shortcode issue, not sure where it goes

 *  [xiabolai](https://wordpress.org/support/users/xiabolai/)
 * (@xiabolai)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/where-does-this-code-go/)
 * i’m using a plugin that uses a shortcode. everything’s fine, EXCEPT i cannot 
   get text i write in the post to appear ABOVE the shortcode. no matter what i 
   do, the text always appears BELOW the shortcode generated content.
 * **for example, if i write this in a post:
    
   intro copy, intro copy, intro copy
   [
   wpecards]
 * **it always appears like this:
    
   [wpecards]
    intro copy, intro copy, intro copy
 * i read something about having to use “return” instead of “echo” in the plugin,
   but i didn’t write the plugin, nor am i a programmer.
 * i did find this code which is supposed to place the text above the shortcode,
   but i don’t know where it goes:
 *     ```
       ob_start();
   
       [PHP script or function call]
   
       $result = ob_get_contents();
       ob_end_clean();
       return $result;
       ```
   
 * can anyone help? thanks!

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

 *  [bygraceuk](https://wordpress.org/support/users/bygraceuk/)
 * (@bygraceuk)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/where-does-this-code-go/#post-1615179)
 * This worked for me:
 *     ```
       function sample_shortcode() {
       ob_start();
       include 'sample_shortcode.php';
       $result = ob_get_contents();
       ob_end_clean();
       return $result;
       }
       add_shortcode('sample_shortcode', 'sample_shortcode');
       ```
   
 *  [bygraceuk](https://wordpress.org/support/users/bygraceuk/)
 * (@bygraceuk)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/where-does-this-code-go/#post-1615180)
 * As with regards to where it goes. Put it in your plugin code and put the sample_shortcode.
   php in the same directory. (Best to put your plugin in its own folder inside 
   plugin folder.
 * Or you can put it in functions.php in your theme again make sure the file is 
   in the same directory. Good luck and let me know if it worked for you.
 * Thanks.

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

The topic ‘found code to fix shortcode issue, not sure where it goes’ is closed 
to new replies.

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [bygraceuk](https://wordpress.org/support/users/bygraceuk/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/where-does-this-code-go/#post-1615180)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
