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 );
Paste the above code snippet into the custom plugin created using the instructions here.
You can create a child theme too and paste the code in the child theme's functions.php.