You’ll have to edit your feed generator files (wp-rss2.php/wp-atom.php) to do what you want. They have a loop just like the main of WP, so you can get a post’s content’s and process it to your heart’s content.
Save it as a new file, and point your feed reader at it.
I can’t get it working whatever i do :-((((
So, http://mydomain.com/feed/rss2 is the rss feed. It contains something like that:
<?php echo “12345678910”; ?>
What should i do in order to have php tags parsed BEFORE they appear inside CDATA?
May be someone could point me the right direction?
Help me, please!
Ally, maybe you need to be more specific. the
<?php ... ?>“tags” as you call them are parsed perfectly fine in the feed generator files.
Maybe you’re trying to put them in places that are already enclosed in PHP tags? In this case, you can leave them off and type in the PHP code directly.
Otherwise, what exactly do you want to achive?
My RSS example:
<?xml version="1.0" encoding="utf-8" ?>
- <!-- generator="wordpress/1.2.2"
- <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<title>My Site Title</title>
<pubDate>Thu, 20 Jan 2005 23:08:15 +0000</pubDate>
<pubDate>Sat, 08 Jan 2005 22:51:20 +0000</pubDate>
<description>wefrwt fdtghryt thyjtyjtyj</description>
<?php echo "12345678910"; ?>
<pubDate>Wed, 05 Jan 2005 21:50:14 +0000</pubDate>
<p><?php include('inc.php'); ?>
My posts contain php code, it is parsed well with runPHP on the pages of my site. All is ok on the site itself but not in RSS feed. Posts contain exactly the content above. What is wrong?
Thanks in advance.
Are you using this RunPHP or another one? I think there are at least 2 plugins with the same name. Assuming you’re using James van Lommel’s (the above linked one), insert the following line in
wp-rss2.phpdirectly below the initial
Then either hack up the code in
wp-rss2.phpto always use the content of the post instead of the excerpt or, just go to Options -> Reading and make sure you’re showing “full text” instead of “summary” for your syndication feeds. This latter option is what I have done and it seems to work.
EDIT: oops forgot the link
Thank you so much! This worked!!!
May be it’s also possible to make runPHP work with post’s excerpt in RSS somehow?
For the older version of RunPHP plugin file, near the end, you’ll find this:
Add lines for the ones you want to hit:
Changes to the new version would be along the same lines.
Kafkaesqui’s solution certainly works, but with one caveat.
The problem with excerpts is that if your post does not have an explicit excerpt set, WordPress will generate one by just grabbing the first so many words. So excerpts may cut your php code in half. If that happens, you’re back to your original problem.
Example. Suppose WordPress generates excerpts which are 12 words long for posts without explicit excerpts. The actual number is much larger, but let’s say it’s 12 for the sake of argument.
Hello, this will echo some text, what will it be? <?php echo 'some text' ?>.
Which would output as “Hello, this will echo some text, what will it be? some text.” if you’re using the full text in your RSS.
Hello, this will echo some text, what will it be? <?php echo
Which would output as “Hello, this will echo some text, what will it be? <?php echo” if you’re using excerpts in your RSS.
Oh, and for the 1.2b3 version, the lines you’re looking for are around line 75:
add_filter('the_content', 'runphp_the_content', 1);
add (for example)
add_filter('the_excerpt_rss', 'runphp_the_content', 1);
This didn’t worked. 🙁
I finally maked it by setting the following:
1) add_filter(‘the_excerpt’, ‘runphp_the_content’, 1);
2) <description><![CDATA[<?php the_excerpt() ?>]]></description>
Is it right? Is it possible to enclose description’s content in CDATA?
I don’t know. Does it work?
Yes. But i don’t know if it’s correct to use CDATA and html tags inside the description.
Ah, I see, sorry.
Yes, I believe you can. To be more specific: I’ve seen other people do this who are far more knowledgeable than I am. I myself don’t know.
- The topic ‘RunPHP in RSS feed?’ is closed to new replies.