Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #318183

    Hi,
    is there a way to determine if we are on a mobile device in functions.php() ?

    Background is this:
    I added a function to display a phone number in a specific way, like so:

    
    function add_stuff_after_main_menu() {
    	$is_mobile = True;
    	if ( is_front_page() || !is_front_page() && $is_mobile ) {
    		echo '<div style="float:right;">';
    		echo '<div style="margin-top: -25px;"><a class="phoneicon phonelink" href="tel:+4912345">+49 12345</a></div>';
    		echo '</div>';
    	}
    }
    add_action('ava_after_main_menu', 'add_stuff_after_main_menu'); 
    

    This works as expected, but for my variable $is_mobile I need a function to get the real functionality.

    Is there a way where I can get the needed information?

    Thanks in advance,
    Michael

    #318187

    Hey Michael!

    Please see – http://codex.wordpress.org/Function_Reference/wp_is_mobile

    Cheers!
    Yigit

    #318191

    Ouch, sorry…I only read the conditional stuff, but missed this one.

    Thank you and have a nice weekend.

    #318195

    Hey!

    No worries at all Michael. You too have a nice weekend :)

    Regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘is_mobile() in functions.php’ is closed to new replies.