0

I noticed there are plugins to allow shortcode usage in widgets, and they obviously work on posts/pages, but they don't seem to work when added directly to the theme files.

Is there a way to allow shortcodes to work when added to a theme file?

1

Try do_shortcode()

<?php echo do_shortcode('[your_shortcode]');?>
1

if you are trying to use shortcodes in PHP templates then you need to use this function :

do_shortcode()

check this out :

https://developer.wordpress.org/reference/functions/do_shortcode/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.