Are shortcodes not allowed in themes?

tips-and-tricks

#1

Are shortcodes not allowed to be built into a theme?

I have seen many threads which says a new plugin needs to be built instead.

But I have also seen a lot of themes published here already that has shortcodes.

Can anyone confirm please?


#2

This is a part of bullshit wordpress philosophy. Reviewers every time requires this from me, but I still not understand - WTF? My shortcodes won’t work properly without my theme, so why I should place them into a separate plugin?

Furthermore this makes me some troubles in development process. I can’t use theme’s function as I can’t be sure that is my theme is activated. Also I need to create a new zip archive and place to theme package every time I make a change.


#3

So, it is true?

A separate plugin needs to be created for shortcodes?


#4

you could call add_shortcode in a hook “after_setup_theme” to fix this problem


#5

No. There is not problem in hooks. There is problem in reviewers.

They run your theme with Theme Check plugin and it displays a warning about add_shortcode function, because its a plugin-territory(theme check thinks so). And you can’t get approved until these warnings are “fixed”. :unamused:


#6

Yes. This is requirement for ThemeForest(for WordPress themes).


#7

All shortcodes need to be added by a plugin, the simple reason is that a customer may change themes and will expect the shortcodes to continue working… they may not be styled “correctly” but they will work… Adding them into the theme means the client might have to redo all their content as the shortcodes will stop working when they change theme.