Feed-Only and Hide-in-Feed Shortcodes
Adds [feed_only] and [hide_in_feed] shortcodes, so you can show a special message to RSS subscribers or keep interactive parts of a post out of feeds.
Opens WPIDE on
Code
add_shortcode( 'feed_only', function ( $atts, $content = '' ) {
return is_feed() ? do_shortcode( (string) $content ) : '';
} );
add_shortcode( 'hide_in_feed', function ( $atts, $content = '' ) {
return is_feed() ? '' : do_shortcode( (string) $content );
} );
Notes
Example: [hide_in_feed]Interactive calculator here[/hide_in_feed][feed_only]Visit the post to use the calculator.[/feed_only]
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.