Exclude older content by date
-
I have a site with a lot of content and we have hit our limit, we don’t want it to be indexed if its older than say 1-2 years, i tried this code but got a critical error.
function wpswa_support_should_index_post( $should_index, $post ) { global $post; // Check if post date or modified date is older than 2 years, if yes, return false to prevent indexing. if (strtotime($post->post_date) < strtotime('-1 year') && strtorime($post->post_modified) < strtotime('-1 year')){ return false; } // Otherwise return our original value return $should_index; } add_filter( 'algolia_should_index_post', 'wpswa_support_should_index_post', 10, 2 ); add_filter( 'algolia_should_index_searchable_post', 'wpswa_support_should_index_post', 10, 2 );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Exclude older content by date’ is closed to new replies.