WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a mobile and a desktop theme for my website , but the shortcodes in my desktop theme are a lot more functional than the ones in my mobile theme, I use only the shortcodes in my desktop theme, but as expected, the shortcodes in my desktop theme don't parse in my mobile theme.

I want some of the shortcodes in my desktop theme to parse in my mobile theme too.

I've read that the do_shortcode() function does the trick but I don't know how to implement it in my mobile theme.


share|improve this question
Have you tried to put the shortcodes into a plugin? That’s the only place where shortcodes should be registered. They would work then in all themes. – toscho Mar 2 '14 at 18:54
Thank you so much toscho, my theme has a php file called "shortcodes.php" do I put the entire code in my plugin after the plugin's headers? Also, do I put the codes in my theme's functions.php file in my plugin too? – Feyisayo Mar 2 '14 at 19:57
The shortcode callback handler function (named in the second argument for add_shortcode( 'shortcode_name', 'callback' )), might use other theme functions. We don’t know that, so we cannot say, what exactly you need. Read and understand the code. Then create the plugin. You can look at one of my very old shortcode plugins to get the idea. – toscho Mar 2 '14 at 20:09
Hi toscho, I tried creating the plugin by pasting the codes in my theme's shortcodes.php file but I got a fatal error of a function already declared in my theme's files. This is a snippet of whats in my theme's shortcodes.php file add_shortcode( 'box', 'wellthemes_msgbox_shortcode' ); function run_box_shortcode( $content ) { global $shortcode_tags; $orig_shortcode_tags = $shortcode_tags; remove_all_shortcodes(); add_shortcode( 'box', 'wellthemes_msgbox_shortcode' ); $content = do_shortcode( $content ); $shortcode_tags = $orig_shortcode_tags; return $content; } – Feyisayo Mar 2 '14 at 23:18
You have to move the code, duplicates are not allowed in PHP. – toscho Mar 3 '14 at 1:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.