Support » Themes and Templates » Best way to: run regular theme and shortcodes mobile theme in tandem

  • red.rover


    I’m currently using one main theme for my WP install, that has a number of handy shortcodes and customisation options. It presents very well.

    I installed a mobile theme, and added a plugin to detect for mobiles and present that theme instead.

    But the problem of course is that the content in the main theme has shortcodes and pages with sidebar navigation that doesn’t play well with the mobile theme. The shortcodes show up as simply text.

    I’m not sure the best way to fix this. I have considered simply making mobile-specific pages and a mobile-specific menu, but that becomes an SEO issue because you’re doubling up on content. And it means mobile users visiting a regular link will have problems. The same can be said for making a subdomain for it.

    In Drupal page elements are coded into the template files, and you can print out simply the body text and the body pictures separate to the rest. One solution could be to use this (unideal) method, and hard code a front page design and others?

    Can anyone tell me their solution to this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,
    I’ve also run into the same problem. I tried some codes in the functions.php of the mobile template to remove shortcodes, which does remove them- but the content that is wrapped in the shortcode is also removed. Would love any suggestions on this. thanks!

    Just figured it out, i copied the code from the plugin (strip non registered shortcodes) into my mobile themes function.php file. worked like a charm. remvoes the codes while leaving the content.

    function strip_nonscodes($text){
        global $shortcode_tags;
        if(!(empty($shortcode_tags) || !is_array($shortcode_tags))){                    
            $exclude_codes = join( '|', array_map('preg_quote', array_keys($shortcode_tags)));           
            $text = preg_replace("/\[(?!(".$exclude_codes."))(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s",'', $text);  #strip shortcode
        return $text;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Best way to: run regular theme and shortcodes mobile theme in tandem’ is closed to new replies.