Awesome. Thanks a ton for the help. This should keep us from showing old events that have already passed.
The other issue we were concerned about was if someone updates the title of an event, which happens regularly. This isn’t then reflected in the stored feed item. This might also be an issue if the date is updated as well. To deal with this we added the following code in functions.php:
<?php
add_action( 'wprss_fetch_all_feeds_hook', 'wi_delete_all_feed_items', 1 ); //Priority 1 so feed items are all deleted before they're fetched.
function wi_delete_all_feed_items(){
$args = array(
'post_type' => 'wprss_feed_item',
'post_status' => array( 'publish', 'future' ),
'cache_results' => false, // Disable caching, used for one-off queries
'fields' => 'ids', // Returns post IDs only
'posts_per_page' => -1,
);
$feed_item_ids = get_posts( $args );
foreach( $feed_item_ids as $feed_item_id ) {
$purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
}
wp_reset_postdata();
wprss_log( sprintf( 'All feed items deleted: %1$d', count($feed_item_ids) ), __FUNCTION__, WPRSS_LOG_LEVEL_INFO );
}
?>
We adapted this from a function within the plugin and it deletes all of the feed items before every fetch, ensuring the events are always accurate.
Aside from the concern of running this too frequently, do you see any issues with this approach? I think we’re almost there so thanks again.
Jonathan