[wp-hackers] How to change the sorting order by of a custom post type's rss feed?

Otto otto at ottodestruct.com
Mon Sep 27 17:40:45 UTC 2010

On Mon, Sep 27, 2010 at 11:31 AM, Bjorn Wijers <burobjorn at gmail.com> wrote:
> Hi,
> I've been trying to setup a (rss) feed for my custom post type.
> This works using the url parameter post_type.
> For example:
> http://wordpress.com/feed/?post_type=my_custom_post_type
> However I would like to change the sorting of the custom posts based on a
> meta key and value.
> I expected something like this:
> http://wordpress.com/feed/?post_type=my_custom_post_type&order_by=meta_key
> Can somebody point me in the right direction on how to achieve this?
> Thanks in advance!

Well, first, it's actually "orderby". Secondly, I'm pretty sure that
orderby is one of the query variables that is "internal only". You
can't set it via the URL query string.

What you really should do is to make a custom feed. This is actually
much simpler than it sounds.

function my_custom_feed() {
// this is your custom query, to change the main one
	load_template( ABSPATH . WPINC . '/feed-rss2.php' ); // load the rss2
feed output

Then you can get this feed via /feed/customname.

Also, that's a simple example. You can actually do anything you want
to the query there.


More information about the wp-hackers mailing list