In the past, we have shown you how to add a shortcode in WordPress. We have also shown you how to use the shortcodes in your WordPress themes. In this article, we will show you how to use shortcodes to create feed only content.
Normally, folks that read your content via feed are among your most loyal users because they usually subscribe to it one way or another. So you can offer your feed user extra information, encourage them to follow you on new venues, or even show them special offers without knowing a whole lot of code. All you have to do is open your theme’s functions.php file and paste the following code:
function feedonly_shortcode( $atts, $content = null) {
if (!is_feed()) return "";
return $content;
}
add_shortcode('feedonly', 'feedonly_shortcode');
After you have pasted this code, you can utilize it when writing your article. An example of how you would use the code would be:
[feedonly]Dear RSS readers, I’d really appreciate if you followed me on twitter (@wpbeginner).[/feedonly]
Simple, yet effective.
All credits for this post goes to Konstantin






