1. Home
  2. FAQs
  3. How do I insert the shortcode using PHP (template include)?

How do I insert the shortcode using PHP (template include)?

To use a shortcode inside a page template, you need to know which page template file you want to insert the shortcode into. This could be a custom template file that you’ve created or one of the default page templates that comes with your WordPress theme. Once you have located the page template file, open it in a text editor such as Notepad. 

To insert the do shortcode, 

  • Simply copy and paste the PHP function: <?php echo do_shortcode(‘[sp_easyaccordion id=”x”]’); ?> into the appropriate place in your template file. 
  • Save the page template file. 
  • Go to the front end and refresh the page to see the changes.
Updated on March 3, 2026