Posted on

Taxonomy page search

To include taxonomy pages (categories, tags, custom taxonomies) in the search, enable the option in the options page. There’s also the option to choose which taxonomies are included. By default everything is indexed.

Currently the title of the taxonomy is indexed with the description field. Indexing other fields isn’t currently possible. Taxonomy pages should be automatically updated in the index whenever they are edited.

In the search results template, avoid get_permalink(), as it doesn’t work. the_permalink() works and returns the correct permalink. You can use relevanssi_get_permalink(), if you don’t want to echo the permalink directly.

In the post object created from the taxonomy page, $post->post_title contains the name of the taxonomy, $post->post_content has the description, $post->link has the permalink and $post->post_type will contain the name of the taxonomy.

If you want to modify the post objects Relevanssi creates from the taxonomies, you can use the relevanssi_taxonomy_term_to_post filter.

  • I’m using the free version. At the moment the search result shows the product title and the whole description. However i’d like it to show the product image (the 1st one would be fine) and the price. Is it possilbe?? Any help would be highly appreciated! Many thanks.

    • That is just a question of setting up your search results template to show the product image and price. That should not be particularly tricky, given some HTML and PHP understanding.

      • Thank you vvvvvvvvvery much for the reply. The guy who set up the website for me has gone and i’m on my own now:(. So should i do it in relevanssi/relevanssi.php file or somewhere else? Sorry for asking such a silly question but i’m not a technical person at all. Many thanks!

        • No, you’re not supposed to touch the Relevanssi plugin files at all. The search results template is actually part of your theme, and can usually be found in the search.php file in your theme folder.

          If you’re not a technical person at all, I recommend hiring someone to do it for you, as it probably requires some PHP knowledge. Anybody with a decent level of WP theme knowledge can do it.

          • Will do that. Many thanks again!!

  • i sell books and using your free plugin to search in my store. i really like it, only i am not succeeding with the taxonomy search. i add my “author” taxonomy to “Custom taxonomies to index” but when i search for an author name it doesnt show any result.

    reading here i understand its a premium option only, or am i doing something wrong?

    • I’m guessing here, but I think the problem may be caused by a conflict, since “author” can also mean the author of the post. Try renaming your taxonomy to “book_author”. That might help.

      Finding posts by taxonomy is available in free version, it’s just finding taxonomy term pages is restricted to premium.

      • is it possible to use something like

        • Well, you can try. I’m not sure about the period in it, underscore will definitely work.

  • Esteban

    Hi. In my site, Relevanssi is not indexing custom post type. They are marked like public and not excludad from search, even Relevanssi is not respecting this trought options page. ¿What can be hapennig? WP 3.5, Relevanssi Free last versión.

    • There is usually a reason. Are you sure Relevanssi is not indexing it? Do the custom posts not appear in the database? It can be that Relevanssi is indexing them fine, but the problem is in searching.

  • freshd

    I have the premium version installed and configured to index my taxonomies, including a custom taxonomy. When searching, these taxonomy pages are not coming up in the results. Isn’t this supposed to be possible with the premium version?

    • Yes, that is supposed to be possible. You’ve checked the correct taxonomies on the *lower* list of “taxonomies to index” on the Relevanssi settings page? You’re sure you’re getting your search results from Relevanssi?

  • We’d like to be able to restrict the search results to a Page in the current section of the site where the user is. A section of the site is a Folder for a Page. Here’s an example of the hierarchy with Pages:

    I would want the site to either search all bicycle pages or all moped Pages. In my research through your documentation I’ve found ways to use categories and tags for Posts, and it appears that you recommend Taxonomies for Pages. Should I use a custom field to create a (seemingly duplicate) Taxonomy on all of my pages within a certain section, or is there a simpler way to simply filter results to the “bicycle” or “moped” folders?

    Thanks so much for your help!

  • elpoto

    This might sound strange, but I could not find an answer to this:
    Does this setting allow me to find posts from the selected taxonomies or should it show an actual link to the taxonomy-archive?

    • It shows a link to the taxonomy term page. The other taxonomy setting (the one that is available in free Relevanssi) will find the posts that have the taxonomy term present.

      • elpoto

        that explains a lot, thank you 🙂

  • Michele

    I’m using the free option. Have a custom post type with it’s own set of categories/taxonomy. The front end searches the posts fine. It does not bring up the category pages. The back end finds nothing in the posts but does work for the categories.

    Is this a free/premium issue or am I just not adjusting the settings properly?