Title: Shortcode executing in Edit Page screen on Save
Last modified: August 20, 2016

---

# Shortcode executing in Edit Page screen on Save

 *  [Dharma](https://wordpress.org/support/users/dharmashanti/)
 * (@dharmashanti)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executing-in-edit-page-screen-on-save/)
 * I am currently working on a plugin that uses a shortcode to pull in a list of
   posts with the custom post type of “fan_fiction” (which is the same as the shortcode
   slug).
 * My problem is that when I type the shortcode [fan_fiction] in the Edit Page window
   and then hit publish, it renders the code in the edit window rather than just
   saving the shortcode. Considering that the function for the shortcode is running
   a custom wp_query loop, executing the shortcode on the Edit Page screen is a 
   problem.
 * You can view the code for the shortcode function [http://pastebin.com/Hb5vMRPS](http://pastebin.com/Hb5vMRPS).
 * I can’t for the life of me understand what is causing it to execute the shortcode
   on the backend. There are no other active plugins. The theme I am using this 
   on is Twenty-Eleven with WP 3.4.1.
 * I have Googled this and searched the WP Forums. No mention of this happening 
   to anyone else.
 * Please help!

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

 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executing-in-edit-page-screen-on-save/#post-2906482)
 * Sorry for suggesting this… but have you familiarized yourself with the WordPress
   Shortcode API?
 * [http://codex.wordpress.org/Shortcode_API](http://codex.wordpress.org/Shortcode_API)
 *  Thread Starter [Dharma](https://wordpress.org/support/users/dharmashanti/)
 * (@dharmashanti)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executing-in-edit-page-screen-on-save/#post-2906543)
 * Hi Josh,
    Yes, I did. And I just discovered the source of the problem. While 
   I have discovered a workaround, I don’t know exactly what was triggering it.
 * It turns out the problem wasn’t in my shortcode function at all. I had a separate
   function that was using the ‘save_post’ hook in order to paginate single posts
   in my custom post type.
 * The pagination function code can be viewed at [http://pastebin.com/sFe6v2RR](http://pastebin.com/sFe6v2RR).
 * I would love to learn what it is in this code that’s rendering the shortcode.
   Otherwise, I’m happy with my workaround.
 * My workaround involved using the $template global variable to determine the template
   file being used and only to execute the pagination function if the template is
   for the single custom post type.
 * Hope this helps someone who runs into a similar situation. Peace out!

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

The topic ‘Shortcode executing in Edit Page screen on Save’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Dharma](https://wordpress.org/support/users/dharmashanti/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/shortcode-executing-in-edit-page-screen-on-save/#post-2906543)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
