Title: Shortcode in php in template file
Last modified: September 28, 2018

---

# Shortcode in php in template file

 *  Resolved [robhern135](https://wordpress.org/support/users/robhern135/)
 * (@robhern135)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/shortcode-in-php-in-template-file/)
 * Hello!
 * I’m trying to use the restricted shortcodes to restrict entire parts of page 
   templates as below. I consulted the docs but it’s not working, what am I doing
   wrong?
 *     ```
       <?php echo do_shortcode('[restricted]'); ?>
       /*code here */
       <?php echo do_shortcode('[/restricted]'); ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [etoilewebdesign](https://wordpress.org/support/users/etoilewebdesign/)
 * (@etoilewebdesign)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/shortcode-in-php-in-template-file/#post-10733754)
 * That is the correct way to use the WordPress do_shortcode method. You just have
   to make sure you’re inserting it in the right template and in the right place
   in that template. As we don’t know your theme or site, it would be hard for us
   to suggest exactly where you need to insert it. You need to find out which theme
   template controls the content you want to restrict and insert the do_shortcode
   in the correct places in that template.

Viewing 1 replies (of 1 total)

The topic ‘Shortcode in php in template file’ is closed to new replies.

 * ![](https://ps.w.org/front-end-only-users/assets/icon-128x128.png?rev=1805921)
 * [Front End Users](https://wordpress.org/plugins/front-end-only-users/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/front-end-only-users/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/front-end-only-users/)
 * [Active Topics](https://wordpress.org/support/plugin/front-end-only-users/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/front-end-only-users/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/front-end-only-users/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [etoilewebdesign](https://wordpress.org/support/users/etoilewebdesign/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/shortcode-in-php-in-template-file/#post-10733754)
 * Status: resolved