0

I learned that I can only put in the code for handling my shortcode through the theme's functions.php

But I was thinking of making it a plugin rather than a theme. How can I achieve that?

2 Answers 2

4

There is no difference. This is a complete shortcode plugin:

/* Plugin Name: blogname */
add_shortcode( 'blogname', 'get_bloginfo' );

Usually, you should never register shortcodes in a theme, because the content will be useless after a a theme switch. So, a plugin is the better option.

1
  • You're absolutely right. I'm a dumbass x_x (it's somehow working now) May 20, 2013 at 12:39
0

Totally agree with toscho but I would use a must-use plugin in this case. In this way nothing will prevent shortcode from executing because Must-Use plugins can not be deactivated through WordPress admin.

4
  • I disagree. Must-use plugins should be reserved for very few use cases: super-important functionality that keeps the site running. Shortcodes don’t fall under this category.
    – fuxia
    May 21, 2013 at 7:06
  • That' s kinda a point. But if plugin is deactivated or if function is deleted in functions.php you'll get [shortcode] on your posts. That's what you want ?
    – JMau
    May 21, 2013 at 11:48
  • It is ugly, but not critical. On the other hand: when a shortcode callback returns an error message after an upgrade, you probably want to turn it off fast.
    – fuxia
    May 21, 2013 at 11:50
  • "not critical" < depends. I mean ok this would not take the site down but let's say you use more than 1 shortcode in your post this could be hard for reading not to mention UX.
    – JMau
    May 21, 2013 at 12:08

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.