I am working on a WordPress podcast site that uses a shortcode to display the mp3 player in the content area. This normally isn’t that big of a deal, but the shortcode was causing the atypical player code to show up in the feed itself, resulting in weird media inclusions from the player, and causing the podcast description in iTunes to break entirely.
The solution I found was adding this code to your functions.php file:
function bd_shortcode_killinfeed( $atts, $content ) {
if ( ! is_feed() )
return apply_filters( ‘the_content’, $content );return ”;
}
add_shortcode( ‘killinfeed’, ‘bd_shortcode_killinfeed’ );
Once you add that, all you need to do is wrap whatever content you don’t want in the feed in [killinfeed] tags. Once you do that, your problemsĀ disappear. From your feed.
The cool part is that this code totally works in reverse. Say you want to encourage people to subscribe to your RSS feed, and as an incentive, you tell them that there’s exclusive content in posts on the feed. Add this code to your functions.php file, and you’ll now have a shortcode [addtofeed] that will publish content exclusively to your feed, and vanish on your blog.
function bd_shortcode_addtofeed( $atts, $content ) {
if ( is_feed() )
return apply_filters( ‘the_content’, $content );return ”;
}
add_shortcode( ‘addtofeed’, ‘bd_shortcode_killinfeed’ );
Easy as pie. This is based on the code posted by Jason from DesignPX. Thanks dude!