feedzy-rss-feeds
feedzy-rss-feeds copied to clipboard
Add option to remove duplicate posts in Feedzy Block Settings
What problem does this address?
A user asked about the possibility of removing duplicate posts from the Feedzy block.
ref: https://secure.helpscout.net/conversation/2476456248/399930?viewId=212385
What is your proposed solution?
Under the Content tab > Feed Source, include a new toggle to remove duplicate posts, similar to what we have in Feed2Post.
Will this feature require documentation? (Optional)
Yes, it requires documentation.
@AndreeaCristinaRadacina,
Doesn't this code snippet help for the scenario described by the user? https://docs.themeisle.com/article/942-in-feedzy-how-do-i#eliminate-duplicate
Hey Vytis,
Thank you for your reply! Based on the latest replies, it looks like it doesn't.
However, my inquiry referred more to the idea of having it integrated into the plugin for consistent behavior among the feed display methods.
The user has shared the following feed URLs https://www.alcatrax.it/feed, https://www.ilrapitaliano.it/feed/, and https://www.hiphopitaly.com/feed. However, the solution mentioned in https://docs.themeisle.com/article/942-in-feedzy-how-do-i#eliminate-duplicate does not work with the Feedzy block.
@AndreeaCristinaRadacina, @poonam279,
The custom code doesn't work for this customer because custom code checks for duplicates by permalink. He's using 3 different feeds and all 3 URLs (domains) are different so permalinks aren't the same, that's why custom code doesn't find them as duplicates.
They have same content and same title, so we need to modify the custom code to find duplicate titles and then it will work for him (tested with his feeds).
Here is the working code for him (which checks for titles and removes duplicates):
function tifd_feedzy_remove_duplicates( $items, $feedURL ) {
$uniques = array();
foreach ( $items as $item ) {
if ( isset( $uniques[ strval( md5( $item->get_title() ) ) ] ) ) {
continue;
}
$uniques[ md5( $item->get_title() ) ] = $item;
}
return array_values( $uniques );
}
add_filter( 'feedzy_feed_items', 'tifd_feedzy_remove_duplicates', 10, 2 );
Thanks @vytisbulkevicius, This code works as expected. It removes the duplicates based on the titles on the frontend. However, they are still visible in the backend. Screenshot: https://vertis.d.pr/v/N4mFvn
Yes, it was always like this @poonam279 but we can keep this in mind to have as a feature inside block not with a custom code so it would work in backend as well but we won't prioritize this now