Filter Search Results front-end

  • I've done this with Javascript before. All I did was add a data element to each search result item to identify which type it was, eg: data-filter="shop". In my case it was so that I could filter a site-wide search and display either blog posts, articles, products or everything. I'm not sure this was the best approach but it works and I'm more comfortable with javascript than PHP so it was my go-to solution. You could do something similar to filter by date as well.