Title: How to use SHORTCODE_UI_DOING_PREVIEW?
Last modified: August 31, 2016

---

# How to use SHORTCODE_UI_DOING_PREVIEW?

 *  Resolved [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * (@diegoliv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/)
 * Hi!
 * I’m trying to setup a different view for my shortcode on TinyMCE, like a placeholder.
   From what I saw, there’s the **SHORTCODE_UI_DOING_PREVIEW** constant to help 
   doing that. I’m using this code on my shortcode function:
 *     ```
       if( SHORTCODE_UI_DOING_PREVIEW ){
       	$html = 'PLACEHOLDER';
       } else {
       	$html = 'REAL CONTENT';
       }
       return $html;
       ```
   
 * But the shortcode renders only the placeholder, both on TinyMCE and the frontend.
   Am I doing something wrong?
 * Thanks for any help!
 * [https://wordpress.org/plugins/shortcode-ui/](https://wordpress.org/plugins/shortcode-ui/)

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

 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986619)
 * > But the shortcode renders only the placeholder, both on TinyMCE and the frontend.
   > Am I doing something wrong?
 * Could be, but it’s hard to say from this code snippet (which seems fine). Can
   you provide more details on your setup? Are you rendering the editor on the frontend
   by chance?
 *  Thread Starter [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * (@diegoliv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986664)
 * Hi, Daniel, thanks for your response!
 * I can’t provide here direct access to the file containing the issue because is
   a private project for a client. But I can send you a secret gist by email so 
   you can take a look at the entire code if you want. What do you think?
 * We’re not rendering the editor at the frontend. At the backend, we created a 
   page and added the shortcode. The placeholder shows up correctly. But at the 
   frontend, instead of rendering the shortcode, it just renders the placeholder.
 * I took a look with WP_DEBUG on and we’re getting this error on the frontend page
   that contains the shortcode:
 *     ```
       Notice:Use of undefined constant SHORTCODE_UI_DOING_PREVIEW - assumed 'SHORTCODE_UI_DOING_PREVIEW' in (...)
       ```
   
 * Seems like is related to the issue – if the SHORTCODE_UI_DOING_PREVIEW constant
   is assumed as defined at the frontend too, it’s logical that it just renders 
   the placeholder, right?
 * Thanks for the help!
 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986666)
 * Can you instead try:
 *     ```
       if( defined( 'SHORTCODE_UI_DOING_PREVIEW' ) && SHORTCODE_UI_DOING_PREVIEW ){
       	$html = 'PLACEHOLDER';
       } else {
       	$html = 'REAL CONTENT';
       }
       return $html;
       ```
   
 * You’re getting the error notice because the constant is only being defined in
   the admin ajax context.
 *  Thread Starter [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * (@diegoliv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986668)
 * Yep, that did the trick. Now it’s working great!
 * Thanks, Daniel!
 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986669)
 * +1

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

The topic ‘How to use SHORTCODE_UI_DOING_PREVIEW?’ is closed to new replies.

 * ![](https://ps.w.org/shortcode-ui/assets/icon.svg?rev=1130575)
 * [Shortcake (Shortcode UI)](https://wordpress.org/plugins/shortcode-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcode-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcode-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcode-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcode-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcode-ui/reviews/)

## Tags

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

 * 5 replies
 * 2 participants
 * Last reply from: [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode_ui_doing_preview/#post-6986669)
 * Status: resolved