Created
March 31, 2018 21:15
-
-
Save Auke1810/deea46c2a32cd0fd4d78e93be3bc0841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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