Title: how to use shortcode widget into php code
Last modified: November 18, 2016

---

# how to use shortcode widget into php code

 *  Resolved [jayapriyaaktis](https://wordpress.org/support/users/jayapriyaaktis/)
 * (@jayapriyaaktis)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/)
 * Hi,
 * How to use this widget short code in php code. Is there any options.

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

 *  Plugin Author [shazdeh](https://wordpress.org/support/users/shazdeh/)
 * (@shazdeh)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8452956)
 * Indeed, you can use:
 *     ```
       <?php
   
       Widget_Shortcode::get_instance()->do_widget( array(
           'id' => 'text-1'
       ) );
       ```
   
 * And that will output the widget with the ID of “text-1”. Although, I would recommend
   to use:
 *     ```
       <?php
   
       echo do_shortcode( '[widget id="text-1"]' );
       ```
   
 *  [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * (@andrewza)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8453020)
 * Hi there,
 * You are able to use the following php code inside your page template
 * `do_shortcode( '<yourshortcodehere>' );`
 * For more information on the do_shortcode, please visit this link -> [https://developer.wordpress.org/reference/functions/do_shortcode/](https://developer.wordpress.org/reference/functions/do_shortcode/)
 * Please keep me posted
 *  Thread Starter [jayapriyaaktis](https://wordpress.org/support/users/jayapriyaaktis/)
 * (@jayapriyaaktis)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8475909)
 * Thank you very much to all. It is working..
 *  [Mr Lucky](https://wordpress.org/support/users/voodoochill/)
 * (@voodoochill)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8748435)
 * None of these are working at all for me, I just see the code on the page or else:
 * `Parse error: syntax error, unexpected '<' in /home/xxx/public_html/wp-content/
   themes/parallax-frame-child/woocommerce/content-single-product.php on line 31`
 *  Plugin Author [shazdeh](https://wordpress.org/support/users/shazdeh/)
 * (@shazdeh)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8872373)
 * [@voodoochill](https://wordpress.org/support/users/voodoochill/): from the error
   I’d guess you’re adding `<?php` tags when it’s not needed, that is causing the
   issue. Try adding just the line:
 *     ```
       echo do_shortcode( '[widget id="text-1"]' );
       ```
   
 * If you still get error, copy the contents of your “content-single-product.php”
   file into pastebin.com and paste the link here, there’s a syntax error that can
   easily be fixed.

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

The topic ‘how to use shortcode widget into php code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/widget-shortcode.svg)
 * [Widget Shortcode](https://wordpress.org/plugins/widget-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/widget-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-shortcode/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [shazdeh](https://wordpress.org/support/users/shazdeh/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/how-to-use-shortcode-widget-into-php-code/#post-8872373)
 * Status: resolved