How to eliminate duplicate feed items.

When you have a large set of feed urls which you would like to display, there is a common issue to remove the duplicates based on their urls.

You can use this code snippet to achieve this: 

function tifd_feedzy_remove_duplicates( $items, $feedURL ) {
	$uniques = array();
	foreach ( $items as $item ) {
		if ( isset( $uniques[ strval( md5( $item->get_permalink() ) ) ] ) ) {
			continue;
		}
		$uniques[ md5( $item->get_permalink() ) ] = $item;
	}
	return array_values( $uniques );
}  
add_filter( 'feedzy_feed_items', 'tifd_feedzy_remove_duplicates', 10, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.