The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

PHP Browser Detection
[resolved] Browser sensitive content for an individual page (2 posts)

  1. gtgphd
    Posted 4 years ago #


    I am using MapPress to display an embedded map on a contact page of my site. The site already adapts its content for mobile viewing, so I don't need to do any major css swapping or anything like that.


    The map looks great on a Desktop browser, but when viewed on a mobile device, it is wider than the screen and becomes hard to view. (I resized the map for now to be slim enough to work well on mobile browsers)

    I want to add some conditional code that would give me the ability to have 2 different short codes in my contact Page depending on browser type.

    For example...

    If on a mobile browser use shortcode A
    If on a non-mobile browser use shortcode B

    I am not the most experienced web developer but I know enough to get by usually. Any help would be greatly appreciated.


  2. Mindshare Labs, Inc.
    Plugin Author

    Posted 3 years ago #

    You can do this like so:

    if(is_mobile()) {
       echo do_shortcode('[mobile-shortcode]');
    } else {
       echo do_shortcode('[desktop-shortcode]');

    See http://codex.wordpress.org/Function_Reference/do_shortcode

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • PHP Browser Detection
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic