How to add a shortcode in WordPress PHP template file?

LearnTips LearnTips How to add a shortcode in WordPress PHP template file?

Tagged: ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4075
    arthur_cz
    Participant
    @arthur_cz

    Sometimes you might have to add a shortcode in WordPress PHP template file to accomplish certain functions.

    Adding a shortcode directly to a WordPress template file will not work. We need to add the shortcode inside opening and closing PHP tags and invoke it with a special function as follows.

    <?php echo do_shortcode('[name_of_shortcode]'); ?>
    Now you can insert the shortcode inside a WordPress template file.
Viewing 1 post (of 1 total)