skarcha
Member
Posted 4 years ago #
Hi,
I'm doing a test plugin using "the_content_rss" hook to filter the content of posts, but my function is never called.
If I use "the_content" or "the_title_rss", it works. What's the problem here?.
This is the code:
<?php
/*
Plugin Name: TestRSS
Plugin URI:
Description: Test plugin
Version: 0.1
Date: Mar 31th, 2008
Author: Antonio Perez
Author URI:
*/
function test_rss($text)
{
$text = "Hello world";
return $text;
}
add_filter('the_content_rss', 'test_rss');
?>
Thanks in advance for your answer.
I am having the same problem.
A workaround would be to use 'the_content' filter and is_feed() conditional tag, but it gets annoying to know that you could use a hook, if it was functioning.
mystyman
Member
Posted 4 years ago #
hi, I just submitted a patch on that ticket which uses is_feed() inside the_content() function to run the the_content_rss hook when appropiate. The issue is appearently the rss2 and atom feeds go through the_content() instead of the_content_rss(). Anyway patch needs testing.
skarcha
Member
Posted 4 years ago #
It works now!. Thanks mystyman.
That ticket (6847) has been closed as "invalid", but I don't understand why--I suspect that the person who closed it didn't realize that it doesn't seem to work with Atom or RSS2 because of http://core.trac.wordpress.org/ticket/8706.
The patch that mystyman suggested works because of the inconsistency in 8706; the person who marked 6847 invalid is correct about how it /should/ work, but not about how it currently /does/ work, and until 6847 is fixed mystyman's patch looks like the right answer to me.
Also, here's another forum thread on it:
http://wordpress.org/support/topic/192997.