Title: shortcode executed before content
Last modified: August 19, 2016

---

# shortcode executed before content

 *  Resolved [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/shortcode-executed-before-content/)
 * Hi.
 * I have this in my functions.php:
 *     ```
       add_shortcode('ataglance', 'ataglance_function');
       function ataglance_function() {
       ?>
       <table>
       <!-- // generate table from xml file -->
       </table>
       <?php
       }
       ```
   
 * And this in my page:
 *     ```
       test copy
       [ataglance]
       ```
   
 * However, the page output (from the_content) is
 *     ```
       <table>...</table>
       test copy
       ```
   
 * How can I make sure the code is executed in order?
 * Thanks

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

 *  Thread Starter [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/shortcode-executed-before-content/#post-1100249)
 * If anyone has the same problem, the answer is that the contents of the ataglance_function
   should be returned not echoed.
 * Jake
 *  [Héctor Cabrera](https://wordpress.org/support/users/ikki24/)
 * (@ikki24)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executed-before-content/#post-1100396)
 * Thanks Jake, this tip really came in handy!

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

The topic ‘shortcode executed before content’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Héctor Cabrera](https://wordpress.org/support/users/ikki24/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executed-before-content/#post-1100396)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
