I just installed the wptouch plugin for auto-styling my blog in mobile devices. How can I style a certain element on my page to be hidden when this view is active?

I.e., in particular, on my blog Under My Hat, I have a WP Follow Me plugin which behaves rather annoyingly on mobile devices, which is why I'd like to hide it. But other elements are custom tables and source code examples that I would like to style differently.

1 Answer 1


I use the following code to intrude myself into WPTouch until I buy a licence :)

Better than simply hiding other plugins is disabling everything you can of it.
And the visitor gain less (and unnecessary) elements to load in their device.

The insert_scripts is pretty straight forward, adjust to your needs.

The remove_scripts I did from a fast analysis of Follow Me code.
To check if you really got rid of the plugin scripts, test using Safari with its Activity Monitor and User Agent simulator (it's perfect on Macs, donnow in Wins).

edit: my original/working script have these calls inside the remove_scripts:

remove_action('wp_head', 'add_css');
wp_deregister_script( 'jqplot' ); 

And right now, re-reading this answer, I think that add_action('wp_head','function'); being used to remove_action('init','function'); may not be correct, would be glad to have a peer review...

Plugin Name: WPTouch Retouch
Plugin URI: https://wordpress.stackexchange.com/q/52026/12615
Description: Add custom scripts to enhance WPTouch and remove WP Follow Me scripts
Version: 1.0

add_action('init', 'wpse_52026_process_wptouch');

function wpse_52026_process_wptouch(){
    if (function_exists('bnc_wptouch_is_mobile')) {
        if(bnc_wptouch_is_mobile()) {
            add_action('wp_head', 'wpse_52026_remove_plugin_scripts', 1);
            add_action('wp_head', 'wpse_52026_insert_wptouch_scripts');

function wpse_52026_remove_plugin_scripts() {
    remove_action('init', 'wp_followme_scripts');
    remove_action('init', 'followme_admin_warnings');
    remove_action('wp_head', 'wp_followme_css');
    remove_action('get_footer', 'show_followme');
    //wp_deregister_script( 'if-there-were-a-registered-script' ); 

function wpse_52026_insert_wptouch_scripts() {
    $today = 'Valencia : Spain : '. date("d/m/Y");
    echo <<<HTML
    <style type="text/css">
        body {background:url('http://www.example.com/wp-content/uploads/pattern.png') fixed !important;}
    <script type="text/javascript">
    jQuery(document).ready( function($) {
        $("div.content").prepend('<div style="margin-left: 13px;"><h4>Site Description</h4><small>{$today}</small></div>');

Attention to the PHP Heredoc syntax <<<HTML

[important update]
When first answered, I forgot an essential part: this has to run as a plugin.

Obviously, putting the code into the desktop theme functions.php file doesn't do the job. And hacking other plugins is kind of pita: at each update you have to re-hack...

[references on how to remove other plugins' styles and scripts] https://wordpress.stackexchange.com/a/40833/12615
Is it possible to stop selected plugins from loading on certain template pages?
How to dequeue a script?

  • Excellent, I wished I could give you a double upvote for the Safari-hint. One question though, where would I place this script? If in the Follow-me code, would WPTouch already be loaded? Or when in the WPTouch code, would the follow-me already be loaded? Or is there some general post-addscripts hook I can use?
    – Abel
    Commented May 14, 2012 at 6:47
  • Sorry mate, I forgot an essential part of the code :/ It has to run as a plugin. I'll update my answer with a plugin header and this extra info.
    – brasofilo
    Commented May 14, 2012 at 10:47

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.