Work

How to insert shortcode into PHP

Especially for those who already know everything, but are just looking for a quick answer on how to insert a shortcode into a wordpress template or another engine, please use this code:

<?php echo do_shortcode( ‘[your_shortcode]’ ); ?>

However, don’t forget about punctuation! The quotes in your shortcode and php code must be different.

That is, if in your WordPress site template, you use the same shortcode, but with two quotes inside ([“…”]), and in your php code, you also use double quotes (“[…]”) , then you need to change one of them to single ones. It is because of such small reasons that shortcodes in wordpress often do not work.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × four =