0

I installed the Plugin "mobble" which provides some more conditional tags. As I want to hide some content for mobile devices I tried to build a shortcode [is_mobile]. But I tried many different ways with return do_shortcode($content); and return $content;or return apply_filters('the_content', $content);but it's simply not doing what I want.. ;(

add_shortcode( 'is_mobile', 'is_mobile_shortcode' );

function is_mobile_shortcode( $atts, $content = null) {
     if ( !is_mobile( ) );
        return $content;
    return '';
}

I would be very happy about some help!

Cheers!

1 Answer 1

0

You've got an extra ";" after if ( !is_mobile( ) ); Your code should look like this:

add_shortcode( 'is_mobile', 'is_mobile_shortcode' );

function is_mobile_shortcode( $atts, $content = null) {
     if ( !is_mobile( ) )
        return $content;
    return '';
}

And you'll use it in this way (just for to be sure you're using it right:

[is_mobile]My Caption[/is_mobidle]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.