How to create a custom rss feed in wordpress?

Can someone help me?

Maybe you should start by stating here EXACTLY what steps you’ve taken already, and what EXACTLY happened or didn’t happen: what specific result or error message, if any, did you get? (“Without success” is not that useful in this regard.)

That example feed you’ve linked to seems quite odd to me. It didn’t validate either but I’m thinking that possibly the validator choked on that stunted Media RSS format.

What results are you after? What is it you need your feed to show?

Anyway, this plugin may generate the feed you are looking for…

If the feed you generate with the above plugin won’t validate then try it in whatever APP needs it anyway or pass it through Heiko Behrens’ Feed Validator then try it.


I managed to solve it. Option 02 is correct.

The template name must start with “rss-” followed by “feedname.php”, but when calling it just use “feedname” in the url: “”.

I had given a name “rss-cpx-feed” and now I changed it to “rss-cpxfeed.php” and it worked.

The dash “-” in the feed name was getting in the way somehow.

Thanks to everyone who helped.


There was another question that would like help.

In option 2, which I am using, the code used, “see below”:
$postCount = 5; // The number of posts to show in the feed
$posts = query_posts('showposts=' . $postCount);

Only defines the number of posts to be displayed.

I wish I could filter by categories, adding 1 or more. Or excluding a category.

You can pass any argument to query_posts() that’s valid for WP_Query. Find the Category Parameters item in the content table after the jump:
(deep linking straight to the section doesn’t work right on this page due to hidden code snippets messing up scroll positioning)

You’ll possibly need to switch to array type arguments instead of string type like you currently use. You cannot mix types and some category arguments require the array type. For example, the array type for your current code:
$posts = query_posts(['posts_per_page' => $postCount,]);

FYI, using query_posts() is discouraged because it discards the query already done and makes a new query. It’s preferred that we alter the main default query through the “pre_get_posts” action. However, this approach is very different than passing desired arguments. If you just want something that works, it may not be something you want to get into. But if you’re interested in doing things properly in the most efficient way, it’s worth learning about “pre_get_posts”, it’s commonly used to alter all manner of post queries.

Source link