• Been using Relevanssi for several years. I have a custom home page, ie. it’s not a Post or a Page. Unfortunately, anything on home.php is not included in the search results.

    How do I get Relevanssi to index the content on home.php?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    You can’t. Relevanssi doesn’t read files. If you want the content in Relevanssi index, store it in a page. If you don’t want to change the template so that it reads the content from a page, I think you could probably create a page that has the content and then have that page redirect to the custom home page.

    Thread Starter suntower

    (@suntower)

    Thanks for the quick reply Mikko. I can never recommend the plug enough.

    One follow up. I there a way to inject static links into the results?

    For example, if the visitor types ‘Gallery’ into the search input I want the first search result to -always- be a custom link that I specify for that term (eg. ‘/home#gallery’ . Can I do that? If so, how?

    Thanks again.

    —JC

    Plugin Author Mikko Saari

    (@msaari)

    Sure you can do that. Relevanssi gives you full control over what’s in the search results.

    There are two ways to approach this.

    1. You can do this on the search results template. In the template file, read the search terms (from get_search_query()), and if the word “gallery” appears, print out whatever content you want before the results.
    2. You can do this with the relevanssi_hits_filter filter hook. If the search query has the word “gallery”, you can create a fake post of your custom link and insert that fake post as the first post in the results.

    In this case, I’d say option 1. is easier to do.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How Do I Index Custom Home Page?’ is closed to new replies.