I'm got an issue here that's stumping me. I'm trying to create a custom RSS feed using add_feed(). The feed seems to have been created successfully, but I'm quite stuck on some bug in the feed template I'm writing.

For some reason, in my code, the_post() seems to return nothing inside the loop. (I've verified this by using print_r). I just don't have access to the typical post-related information that I'd expect.

Even stranger: get_defined_vars() outputs nothing inside the template as well. I wrote up a test script to hosted on another vhost on the same physical machine to verify that PHP is configured correctly, and it seems to be.

Stranger still: despite all of the above, my <item>s aren't coming through blank. Some of the wordpress functions seem to work - just not all of them :/

As a reference, here's the entire template file I'm working on. It's very minimal, but based off of the wp-includes/feed-rss2.php file:

View it on pastebin. (Sorry, tried to put it here, but the formatter was getting pretty confused by it.)

It is not supposed to return anything. It just sets up global variables with info about current post and iterates the loop. Check global $post variable for current post instead.

Even stranger: get_defined_vars() outputs nothing inside the template as well.

That function outputs variable from current scope. Since your templates is loaded inside of some feed-related function it doesn't output global variables because they are out of scope for that function.

Thanks, @Rarst. I ended up solving this one yesterday afternoon, but couldn't post the solution to the forum until now because I'm a new member (and new members must wait before answering their own questions.) Sure enough, it did end up being a scoping issue, like you said. Thanks! (I'd upvote you now, but I don't have the necessary reputation.)
–
chrisallenlaneApr 27 '11 at 14:43