When we have to add some functionality how to determine should I use shortcode or template file?

Ex : I need to add a page to enable front-end post submission.

I can do it creating a template page or using shortcode and add it to a page. How to identify what is best?

1 Answer 1


Actually it depends. If you're adding the functionality through a custom plugin or any third party solution rather than theme then the shortcode is best, otherwise you can use a template. You also can use template file with plugin, but then the theme and the plugin will be tightly coupled. That's kinda not preferred. But you can still do it.

Remember for shortcode, it's better to clean the output buffer.

  • Thanks for the answer. What do you mean by "it's better to clean the output buffer." ?
    – Damithatt
    Commented Oct 26, 2016 at 5:43
  • ob_start() and ob_get_clean() etc. function. Just do a google search. If this answer helped you please accept it. @Damithatt
    – CodeMascot
    Commented Oct 26, 2016 at 5:44
  • i actually heard it was better NOT to clean the buffer. Can you show where you got that it was better.
    – rudtek
    Commented Oct 26, 2016 at 6:42
  • I experienced it. And using it for a long time. Can you please give the reference where you heard that it should not be used with shortcode?
    – CodeMascot
    Commented Oct 26, 2016 at 6:44
  • dude. "experience" isn't a reference or reason. I'm on mobile so only did a quick one minute search but found this link readily that explains a very good reason no to use ob_start if you can avoid it. wordpress.stackexchange.com/questions/41012/…. additionally I think the best reason to use shortcodes is for ease of use for consumers to create dynamic content.
    – rudtek
    Commented Oct 26, 2016 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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