Skip to content

Instantly share code, notes, and snippets.

@aishahenderson
Created June 1, 2018 17:24
Show Gist options
  • Select an option

  • Save aishahenderson/9a3872298f0776efb0761b9e411b9c33 to your computer and use it in GitHub Desktop.

Select an option

Save aishahenderson/9a3872298f0776efb0761b9e411b9c33 to your computer and use it in GitHub Desktop.
WPSearch Exclude Posts After a Specified Time Period During Initial Indexing
<?php
function my_searchwp_indexer_unindexed_args( $args ) {
// TODO: customize $args in any way you'd like, see @link https://codex.wordpress.org/Template_Tags/get_posts
// Example 'after' => date('Y-m-d', strtotime('January 1, 2017' ))
$args['date_query'] = array(
'after' => date('Y-m-d', strtotime('-2 years' ))
);
return $args;
}
add_filter( 'searchwp_indexer_unindexed_args', 'my_searchwp_indexer_unindexed_args' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment