Continue reading Excluding old content from the search

Excluding old content from the search

Is there a way to exclude anything before 2016 from search results? Yes. There are two approaches to this. If you never want to see anything old in the results, it’s best to filter in indexing with relevanssi_indexing_restriction. Add this to your site: add_filter( ‘relevanssi_indexing_restriction‘, ‘rlv_exclude_old_posts’ ); function rlv_exclude_old_posts( $restriction……news post type that are older than one year, you can use: add_filter( ‘relevanssi_indexing_restriction‘, ‘rlv_exclude_old_news’ ); function rlv_exclude_old_news( $restriction ) { $restriction[‘mysql’] .= ‘ AND ( ( post.post_date >= CURDATE() – INTERVAL 1 YEAR ‘ . ” AND post.post_type = ‘news’ ) OR ( post.post_type != ‘news’ ) ) “;…

Read more Excluding old content from the search 2 Comments on Excluding old content from the search
Continue reading Natural-language date queries

Natural-language date queries

I just wanted to be able to type in a date on the search and for the search to come up with all the blog posts for that date. This is one of those tasks that sounds really simple, but is actually complicated. However, this question piqued my interest and turns out it isn’t that…

Read more Natural-language date queries 17 Comments on Natural-language date queries
Continue reading Searching between dates

Searching between dates

…not sure how necessary that is, but it’s best to be safe. Using this would look like this: https://www.example.com/?s=search&from=2018-01-01 would show posts starting from January 1st. https://www.example.com/?s=search&from=2018-01-01&to=2018-01-31 would show posts in January 2018. To get this on the search form, just add two input fields: From: [input type=”text” name=”from” /]…

Read more Searching between dates 17 Comments on Searching between dates