WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. gtgphd
    Member
    Posted 1 year ago #

    Hello,

    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.


    http://www.gtgphd.com/contact-directions/

    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.

    http://wordpress.org/extend/plugins/php-browser-detection/

  2. Mindshare Studios, Inc.
    Member
    Plugin Author

    Posted 1 year 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

About this Topic