WordPress.org

Support

Support » Plugins and Hacks » mobble » [Resolved] Can I use this to switch link URLs

[Resolved] Can I use this to switch link URLs

  • Can I use this to change the URL in a link to a different URL based on whether the visitor to my site is using a mobile vs. regular browser? The two different URLs would go to an external page/listing of products. That external site I have no control over, and it uses two different addresses for its mobile or desktop sites.

    https://wordpress.org/plugins/mobble/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Scott (@scottsweb)

    @scottsweb

    You can use mobble for this (providing your site/host is not using a static cache)… Something along the lines of:

    <?php if (is_mobile()) { ?>
    <a href="http://linkmobile.com">Mobile</a>
    <?php } else { ?>
    <a href="http://linkdesktop.com">Desktop</a>
    <?php } ?>

    Will do what you are after.

    Thank you. I just ended up putting one link in the [device][/device] tags and the other in the [notdevice][/notdevice] tags.

    In a somewhat related issue, do you know how to implement a similar fix in the built-in WP menus?

    Plugin Author Scott (@scottsweb)

    @scottsweb

    You would use similar code to the above in your theme where the menus are output:

    <?php if (is_mobile()) { ?>
       <?php wp_nav_menu( array('menu' => 'Mobile Nav' )); ?>
    <?php } else { ?>
       <?php wp_nav_menu( array('menu' => 'Desktop Nav' )); ?>
    <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Can I use this to switch link URLs’ is closed to new replies.
Skip to toolbar