Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer

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]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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