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.

is there any plugin that will add new quicktag, says:

[hidetext]some text to hide[/hidetext]

and any text inside those tag is hidden from frontpage/archive/etc. It only shown on single post page.

share|improve this question

2 Answers 2

up vote 2 down vote accepted
add_shortcode( 'hidetext', 'my_hidetext_shortcode' );
function my_hidetext_shortcode( $atts, $content = '' ) {
    if( is_single() )
        return $content;
    else
        return;
}

Docs: add_shortcode(), is_single()

Solution is untested.

share|improve this answer

A slight modification on the function above. You'll want to use is_singular('post') instead, unless you also want to target other areas

add_shortcode( 'hidetext', 'rkv_hidetext_shortcode' );

function rkv_hidetext_shortcode( $atts, $content = null) {
    if( is_singular('post') )
        return $content;
    else
        return;
}

tested and works.

share|improve this answer

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.