• Resolved anonymized-12966443

    (@anonymized-12966443)


    I am trying to make the snippet below kick in when it’s not a mobile device using “wp_is_mobile” but I keep failing making it work.

    Please advice?

    function nsplayer() { ?>
    	
    /*MY HTML CODE*/  
      
      <?php
      }
      
    add_action( 'wp_footer', 'nsplayer', 10 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • You don’t have any condition. You should wrap the add_action with a condition.

    Thread Starter anonymized-12966443

    (@anonymized-12966443)

    @tapiohuuhaa can you show me an example?

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @heathcliff2013,

    Here’s how you could accomplish that:

    add_action( 'wp_footer',  function () {
    	
    	// skip this snippet if running on a mobile device
    	if ( wp_is_mobile() ) {
    		return;
    	}
    	
    	?>
    
    	/*MY HTML CODE*/
    
    	<?php
    } );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to disable snippet for mobile or other non-desktop?’ is closed to new replies.