Hide Shortcodes From WordPress RSS Feed

I added Adsense to my content via shortcodes. But Adsense codes appears in RSS too. How can I hide shortcodes from RSS Feed and show only for in posts ?

I am using sahifa wordpress theme.

Related posts

Leave a Reply

1 comment

  1. You will need to alter how the RSS is output.

    All the RSS styling files are located in the wp-includes folder and are titled as follows:

    • feed-rss2.php
    • feed-rss.php
    • feed-rdf.php
    • feed-atom.php
    • feed-atom-comments.php
    • feed-rss2-comments.php

    Then within these files, you need to find where it calls the function the_excerpt_rss(). This calls out the content in excerpt format.

    You will need to enclose this in a function called strip_shortcodes().

    As an example from feed-atom.php line 70:

    <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php strip_shortcodes(the_excerpt_rss()); ?>]]></summary>
    

    Hope this helps