Title: Execute php code in shortcode content in my theme template
Last modified: August 21, 2016

---

# Execute php code in shortcode content in my theme template

 *  [chrysgpc](https://wordpress.org/support/users/chrysgpc/)
 * (@chrysgpc)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/execute-php-code-in-shortcode-content-in-my-theme-template/)
 * First of all thank you very much for this great plugin.
 * I’m trying to use the shortcode directly in theme template. It works to a certain
   point where I tried to put some php code in the content. Below an example :
 *     ```
       <?php
           $phpcode1 = echo esc_attr($EM_Event->event_name,ENT_QUOTES);
           $my_tabs = '
           [su_tabs vertical="yes"]
           [su_tab title="Event Name"]
           <h3 class="event-form-name"></h3>
           <div class="inside event-form-name">
           <input type="text" name="event_name" id="event-name" value="' .$phpcode1. '" />
           <br />
           </div>
           [/su_tab]
           [su_tab title="Title 2"]Content 2[/su_tab]
           [su_tab title="Title 3"]Content 3[/su_tab]
           [/su_tabs]
       ';
       echo do_shortcode( $my_tabs );
       ?>
       ```
   
 * I’ve tried this as well
 *     ```
       <?php
           $my_tabs = '
           [su_tabs vertical="yes"]
           [su_tab title="Event Name"]
           <h3 class="event-form-name"></h3>
           <div class="inside event-form-name">
           <input type="text" name="event_name" id="event-name" value="<?php echo esc_attr($EM_Event->event_name,ENT_QUOTES); ?>" />
           <br />
           </div>
           [/su_tab]
           [su_tab title="Title 2"]Content 2[/su_tab]
           [su_tab title="Title 3"]Content 3[/su_tab]
           [/su_tabs]
       ';
       echo do_shortcode( $my_tabs );
       ?>
       ```
   
 * None of these work. I’m not developer, so I’m struggling a bit here. And I could
   find any similar topic. Any help will be appreciated.
 * Thanks.
 * [https://wordpress.org/plugins/shortcodes-ultimate/](https://wordpress.org/plugins/shortcodes-ultimate/)

The topic ‘Execute php code in shortcode content in my theme template’ is closed
to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [WP Shortcodes Plugin — Shortcodes Ultimate](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [chrysgpc](https://wordpress.org/support/users/chrysgpc/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/execute-php-code-in-shortcode-content-in-my-theme-template/)
 * Status: not resolved