Title: Shortcode Within A get_post
Last modified: August 19, 2016

---

# Shortcode Within A get_post

 *  Resolved [visualadvance](https://wordpress.org/support/users/visualadvance/)
 * (@visualadvance)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-within-a-get_post/)
 * Let me see if I can explain this.
 * 1. In my template I am using this code to display a single post:
    $my_post_id
   = get_post ($postid); $my_content = $my_post_id->post_content; echo $my_content;
 * 2. There is a shortcut inside of the post that I am pulling with the above function.
   But when I pull that post using the get_post listed above, it gets returned as
   a string and the shortcode isn’t executed. So when I do the get_post above, it
   ends up displaying the post as:
    Blah blah blah [my_shortcode_function foo=”bar”]
   blah blah
 * Any clues on how I can modify the get_post call in order to not turn any shortcodes
   into literal strings?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-within-a-get_post/#post-1988063)
 * try:
 * `echo apply_filters('the_content', $my_content);`
 * [http://codex.wordpress.org/Function_Reference/apply_filters](http://codex.wordpress.org/Function_Reference/apply_filters)
 * or
 * `echo do_shortcode( $my_content );`
 * [http://codex.wordpress.org/Function_Reference/do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode)
 * or (if you don’t want the shortcode)
 * `echo strip_shortcodes( $my_content );`
 * [http://codex.wordpress.org/Function_Reference/strip_shortcodes](http://codex.wordpress.org/Function_Reference/strip_shortcodes)
 * (all untested)
 *  Thread Starter [visualadvance](https://wordpress.org/support/users/visualadvance/)
 * (@visualadvance)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-within-a-get_post/#post-1988086)
 * You are a genius.
 * I didn’t try apply_filters yet, but do_shortcode did exactly what I needed. Much
   appreciated.

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

The topic ‘Shortcode Within A get_post’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [visualadvance](https://wordpress.org/support/users/visualadvance/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-within-a-get_post/#post-1988086)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
