WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Shortcode to switch content if mobile or desktop (8 posts)

  1. crashjohnson
    Member
    Posted 2 years ago #

    I'm looking for a plugin that would allow me to display different types of content if the user is visiting on a mobile device or if they are on a desktop. For example, I would like to display a flyer or picture on desktops but text description on mobile.

    For instance:

    [mobile]You are on a mobile device[/mobile]
    
    [not-mobile]you are NOT on a mobile device[/not-mobile]

    I found a plugin that claims to do just this. The problem is that it is, as of this writing, unavailable. Does anyone know of any others that may do this? acmeifmobile.com

    I would like to clarify that I am not looking for something that will display the same content in a mobile friendly way. I am looking, specifically, for something that will display entirely different contact in each environment.

  2. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 2 years ago #

    Set up shortcodes in your functions.php or in a plugin to add an enclosing div around the content so you can designate it mobile or not-mobile - each with a class to enable it to be targeted with CSS. Then use media queries in your CSS & set each type of content to display or not as appropriate

    http://codex.wordpress.org/Shortcode_API

    http://coding.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/

  3. venicedesign
    Member
    Posted 1 year ago #

    @crashjohnson - did you ever find a plugin to do this?

  4. dylanfeltusdesign
    Member
    Posted 1 year ago #

    @crashjohnson @venicedesign - try my plugin Mobile Content

  5. dylanfeltusdesign
    Member
    Posted 1 year ago #

    you can do:

    [computer]Content for only computers here[/computer]
    [tablet]Content for only tablets here[/tablet]
    [mobile]Content for only phones here[/mobile]
    [mobile_tablet]Content for phones and tablets here[/mobile_tablet]
    [ios]Content for only iOS devices only here[/ios]
    [android]Content for only Android devices only here[/android]
    [bb]Content for only Blackberry devices here[/bb]
    [kindle]Content for only Kindle devices here[/kindle]

  6. der-mali
    Member
    Posted 1 year ago #

    Here is another one:

    "WP Mobile Detect"
    http://wordpress.org/extend/plugins/wp-mobile-detect

    Impressing list of shortcodes:
    http://wordpress.org/extend/plugins/wp-mobile-detect/faq/

    ***

    Well, I came to this thread because I need a similar solution:
    I want to do a selection of the content depending on the theme (e.g. theme 1 for desktop, theme 2 for mobile).

    like
    [content_theme1][/content_theme1]
    [content_theme2][/content_theme1]

    Maybe it would be possible to add a function to one of the mentioned plugins which detects the theme and than filters the content!?

  7. dylanfeltusdesign
    Member
    Posted 1 year ago #

    @der-mall This is not something I would like to add to my plugin but if you email me I could certainly help you with this.

    My email is:
    contact@dylanfeltus.com

  8. crashjohnson
    Member
    Posted 1 year ago #

    As it turns out, for me, my theme was responsive and I can just modify some css to hid/unhide divs based on screen size.

    Thank you @ dylanfeltusdesign and @der-mali for your contributions. I'm sure this will help others in the future.

Topic Closed

This topic has been closed to new replies.

About this Topic