The content protected by Pay With a Like appears in the RSS feed

We are using the Pay With A Like plugin, but we have the problem that the protected content appears completly in the RSS feed.

We use the button for inserting the shortcut and insert the content to protect in it:
[pwal id="20038338" description="test"] content to protect [/pwal]

We obviously don't want the protected content to be shown in the RSS feed.

How can we solve this problem?

Thank you for your help.

  • Patrick
    • Support Monkey

    Hi @apasionados,

    Welcome to the forums!

    Try setting "Search Bots See Full Content" to "No".

    I think this should prevent your protected content from showing up in feeds and search engines.

    Just to be sure as to how exactly the plugin handles feeds internally, I'll alert the developer to your question.

    Hope this helps! And thanks for being a member :slight_smile:

  • apasionados
    • WPMU DEV Initiate

    We have added the code to the functions.php of the theme, but it doesn't work as expected.

    We have made several tests and it seems that WordPress strips out the Shortcode codes from the RSS feed:
    [pwal id="20038338" description="test"]
    [/pwal]
    Leaving only the content between the shortcode codes, which shows up in the RSS feed.

    In fact we have checked that WordPress never finds the shortcode code:
    strpos( $content, '[pwal' ) === false
    The strpos is allways false and therefore we can't strip the content out and that's why the preg_replace code is never executed.

    Is there another solution?

    Thanks for your help.

  • Hakan
    • The Incredible Smush

    Hi,

    Use it like this:

    add_filter( 'the_content_feed', 'my_strip_hidden_content', 1 );
    function my_strip_hidden_content( $content ) {
    	// Make a quick check if Pwal is used
    	if ( strpos( $content, '[pwal' ) === false )
    		return $content;
    	// Clear the shortcode and hidden content
    	return preg_replace( '%\[pwal( +)id="(.*?)"( +)description="(.*?)"(.*?)\](.*?)\[( *)\/pwal( *)\]%is', '', $content );
    }

    Cheers,
    Hakan

  • apasionados
    • WPMU DEV Initiate

    Dear Hakan,

    This is the code we have used, but it doesn't work as expected.

    Using this function, WordPress never finds the shortcode code, because strpos( $content, '[pwal' ) is allways false and therefore the preg_replace code is never executed.

    It seems that WordPress strips out the Shortcode codes from the RSS feed before we can search for it in functions.php with the function you provided.

    The shortcode code:
    [pwal id="20038338" description="test"]
    [/pwal]
    doesn't appear in the RSS feed, only the content in between the shortcode.

    Can you test this? We have not been able to solve this issue and stil can't strip out the hidden contents from the RSS feed.

  • Hakan
    • The Incredible Smush

    Hi,

    Testing it on my configuration will not mean anything: Content modifying hooks and functions depend on the theme and other content modifying plugins you are using.

    This hook with this priority should work in all themes:

    add_filter( 'the_content', 'my_strip_hidden_content', 9 );

    Function is the same as above.

    Cheers,
    Hakan

  • apasionados
    • WPMU DEV Initiate

    Dear Hakan,

    We have been testing on a clean installation of WordPress with the standard twentyeleven theme and it seem to us that WordPress strips the shortcodes out before creating the RSS feed.

    Nevertheless we will try what you suggested and keep you informed.

    Thanks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.