wordpress: change rss feed order

December 24, 2010

For some reason I needed my rss feed to sorted not by post date, but by posts’ id as I could have newer post with not the latest post date (some future posts that stll had publish status). To change the rss feed’s order I’ve hooked pre_get_posts:


add_action('pre_get_posts', 'sort_rss' );

function sort_rss( $notused )
{
	global $wp_query;
	if( is_feed() )
	{
		$wp_query->set( 'orderby', 'ID' );
	}
}

That worked for me. Have better solution? Write a comment!

tags: , ,
posted in wordpress by dmitko

1 Comment to "wordpress: change rss feed order"

  1. valerykalashnikov wrote:

    Спасибо за ваше старание и труд! Материал полезный и интересный!

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org