tags:

views:

200

answers:

3

I'm trying to remove the the_guid() function that appears in feed-rss2.php. I've tried remove_action('rss2_item', 'the_guid') or remove_filter but nothing happens. I’ve also tried different hooks like the_content_rss...

The function appears on line 43 of feed-rss2.php, enclosed by <item></item>.

Update

With echo current_filter(), I found that the hook is do_feed_rss2. But I still can't remove the function.

A: 

Looks like line 40 in /wp-includes/feed-rss2.php:

<guid isPermaLink="false"><?php the_guid(); ?></guid>

Try deleting that and see what happens; it's the only reference to the_guid in the file

songdogtech
Deleting is fine. I want to remove it automatically (and replace it with something else) via a plugin or functions.php, so I don't have to manually change it after every WordPress upgrade.
anno
+1  A: 

You can override the output of that function via a filter.

add_filter('get_the_guid','my_get_the_guid');
function my_get_the_guid($guid) {
    $my_guid = 'foo';
    return $my_guid;
}

Using that you can override the GUID output with anything you want. You can't delete the node in the RSS output, but you can control its content. If you want to delete the node all together you could create your own XML template, keep it on your theme, and then use the template_redirect action to force load your template instead of the default.

Hope that helps!

Gipetto
It works ! Thanks.
anno
+1  A: 

Feed Wrangler plugin works great for customizing feeds:

http://wordpress.org/extend/plugins/feed-wrangler/

Basically, install the plugin, denote a feed with a slug (ex: no-guid), then add a feed-no-guid.php file to your theme. You can use the default feed files in wp-includes/ as a base and delete or add whatever items you want. That way, you get complete control of the feed and a clear upgrade path in the future.

Bob Sherron