How to sort feed items by date

You can use this code snippet to sort the feed items alphabetically by their date:

function tifd_feedzy_feed_items_date( $items, $feedURL ) {
	if ( 'http://themeisle.com/blog/feed/' == $feedURL ) {
		usort( $items, function ( $a, $b ) {
			// You can switch the parameters to ge the reverse order. 
			return strcmp( $a->get_date( 'U' ), $b->get_date( 'U' ) );
		} );
	}

	return $items;
}

add_filter( 'feedzy_feed_items', 'tifd_feedzy_feed_items_date', 9, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us