0

I want to use the hide unwanted shortcodes plugin to hide unwanted shortcodes from my desktop theme when my website is visited by mobile users.

I'm currently using the any mobile theme switcher plugin on my website to show a different theme to mobile users but since I'm using different themes and they both use different shortcodes, how can I hide my desktop theme's shortcodes when my website is visited on a mobile device.?

Thanks!

1
  • Please always provide all needed sources to replicate the problem or given task. Those are for e.g. links to used plugins and your theme. Else it would be impossible to replicate your problem or fill the gaps in your code. Provide all this info directly as edit to your question.
    – kaiser
    Feb 28 '14 at 20:03
2

I highly doubt that what is happening is actually process of "activation" in WP terminology. What plugin is likely doing is just filtering data for what theme is currently active, without actually activating/deactivating (which would probably lead to chaotic collisions between different visitors).

The easiest way to hide those shortcodes would probably be to make them empty in a theme that doesn't use them. Something like this should work:

add_shortcode( 'name', '__return_empty_string' );
5
  • Nice and easy solution +1
    – kaiser
    Feb 28 '14 at 20:04
  • Thanks Rarst, do I replace 'name', with shortcodes in my desktop theme? and this code goes into my mobile theme's functions.php file right? Mar 2 '14 at 3:05
  • Oh Never mind Rarst, I figured this out by adding the line add_shortcode( 'name', '__return_empty_string' ); to my functions.php file and replacing "name" with the names of my shortcodes, but adding the code for each of the shortcode. Example, [highlight] shortcode will be like add_shortcode( 'highlight', '__return_empty_string' ); Mar 2 '14 at 5:08
  • @Rarst What if I wanted the shortcodes to parse in my mobile theme also, rather than have them empty? Mar 2 '14 at 23:44
  • @Feyisayo then you'll need to organize code in a way that those shortcode handlers are loaded and added in both themes
    – Rarst
    Mar 3 '14 at 8:21

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.