Posted on

Pin a post for all searches

Relevanssi Premium has tools for pinning posts for specific queries and all searches where the post appears, but what if you want to pin a post for all searches? That’s also possible but requires a bit of code.

Pin the post for all searches and add this function to your site:

PHP

Replace 1234 with the ID of the post you want to pin. This function runs on the relevanssi_hits_filter hook that can be used to modify the search results. The function checks if the post appears in the results; if it doesn’t, it fetches the post object and adds it to the top.

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

Your email address will not be published. Required fields are marked *