Skip to content

Instantly share code, notes, and snippets.

@Auke1810
Created March 31, 2018 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Auke1810/deea46c2a32cd0fd4d78e93be3bc0841 to your computer and use it in GitHub Desktop.
Save Auke1810/deea46c2a32cd0fd4d78e93be3bc0841 to your computer and use it in GitHub Desktop.
<?php
// wppfm feed ides in queue Filter
//
function only_last_week_ids( $ids ) {
$index = 0; // set the index
foreach( $ids as $id ) {
$post_date = get_the_date( 'U', $id ); // get the posts published date
$last_week_date = strtotime( '-1 week' ); // get the date of one week ago
if( $post_date < $last_week_date ) {
// Remove the id from the queue when the product is older than one week
unset( $ids[ $index ] );
}
$index++;
}
// IMPORTANT! Always return the $ids
return $ids;
}
add_filter( 'wppfm_feed_ids_in_queue', 'only_last_week_ids' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment