WordPress.org

Ready to get started?Download WordPress

Forums

mobble
[resolved] Can I use this to switch link URLs (4 posts)

  1. jmducat
    Member
    Posted 6 months ago #

    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/

  2. Scott (@scottsweb)
    Member
    Plugin Author

    Posted 6 months ago #

    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.

  3. jmducat
    Member
    Posted 6 months ago #

    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?

  4. Scott (@scottsweb)
    Member
    Plugin Author

    Posted 6 months ago #

    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 } ?>

Reply

You must log in to post.

About this Plugin

About this Topic