Title: add_shortcode in functions.php output in wrong order
Last modified: August 20, 2016

---

# add_shortcode in functions.php output in wrong order

 *  Resolved [mmtomm](https://wordpress.org/support/users/mmtomm/)
 * (@mmtomm)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/add_shortcode-in-functionsphp-output-in-wrong-order/)
 * Hi,
 * I’m using add_shortcode in the functions.php and when I use it in a page it does
   output in the wrong order.
 * Background.
    I’m using the below function in functions.php where I read a seperate
   php file which only contains some html. I do this, because the content of this
   snippet of html does change periodically and is used in different places also
   outside of WP and I want to change it only in one place.
 *     ```
       function laden_offen_snippet() {
       	$laden_offen = file_get_contents('offen.php', false);
       	echo $laden_offen;
       }
       add_shortcode('offen', 'laden_offen_snippet');
       ```
   
 * In the WP page where I use it there is something like this:
 *     ```
       <h1>Title</h1>
       [offen]
       <p>some paragraph</p>
       ```
   
 * but the problem is that the part of [offen] appears before the Title in the output.
   
   May do I wrong when I use echo in the function above? Or any other idea, how 
   to get on the right place? Thanks a lot Tom

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/add_shortcode-in-functionsphp-output-in-wrong-order/#post-2392597)
 * do not use `echo` in shortcodes – use `return` instead;
 * example:
 *     ```
       return $laden_offen;
       ```
   
 *  Thread Starter [mmtomm](https://wordpress.org/support/users/mmtomm/)
 * (@mmtomm)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/add_shortcode-in-functionsphp-output-in-wrong-order/#post-2392647)
 * Wonderful, thank you very much!
    Tom

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

The topic ‘add_shortcode in functions.php output in wrong order’ is closed to new
replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [mmtomm](https://wordpress.org/support/users/mmtomm/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/add_shortcode-in-functionsphp-output-in-wrong-order/#post-2392647)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
