AddThis inserting scripts in the_excerpt/the_content in custom feeds (4 posts)

  1. john.ritterbush
    Posted 4 years ago #

    I am using the AddThis plugin (v 2.0.6) but am running into a problem where my custom feeds are displaying the AddThis head script the first time that either the_excerpt or the_content is called.

    For example here is one custom feed in particular:

    In that RSS, you can see in the first item block right after the guid (around line 33), the AddThis scripts are being called. In my PHP custom feed, if I comment out get_the_excerpt AND the_content_feed('rss2') the AddThis script goes away. Any idea on either working around this or (if devs are checking here) is it something that needs patching in the plugin?

    Also, likely related, I'm also using the JSON API plugin (v 1.0.7) which is pulling in the same AddThis code before the callback in the returned JSON.

    You can see in this JSON code for example:

    This second issue makes the JSON API plugin unusable as it is no longer valid JSON and I am unable to parse it.

    If you need more info let me know. Thanks in advance for any help you can provide.

  2. Aaron Jorbin
    Posted 4 years ago #

    When you are setting up your custom feed, are you making sure that is_feed is returning true?

    I've asked the developer of JSON API for a hook so that I can make sure the code isn't outputted when requests are made through it - https://wordpress.org/support/topic/plugin-json-api-what-is-the-easiest-way-to-programmatically-determine-if-json_api-is-running?replies=1#post-2098241

  3. john.ritterbush
    Posted 4 years ago #

    Thanks, jorbin. is_feed is returning false. So now...how do I get a custom feed to return true in is_feed? Am I missing something obvious? I used this tutorial for setting up the feed: http://www.seodenver.com/custom-rss-feed-in-wordpress/

    Basically this is added to the functions.php file and a custom template (test-feed-rss2.php) is made:

    function do_feed_test() {
    	$cats = "5293,5294";
        query_posts( array( 'cat'  => $cats ) );
        load_template( TEMPLATEPATH . '/test-feed-rss2.php' );

    Thanks again.

  4. john.ritterbush
    Posted 4 years ago #

    Ok...is_feed is now returning true. My query_posts was messing things up so I pulled the query_posts out of the do_feed_test function and added it to the feed template instead. and made sure not to clear out the global $query_string but append to it.

    HOWEVER...addthis plugin is still dumping in the "AddThis Button Begins" block into my RSS feed even though is_feed = true.

    Any more ideas, y'all?

Topic Closed

This topic has been closed to new replies.

About this Topic