• Resolved Tobias

    (@tobiaseichner)


    Hello,

    on a German dictionary site I use Relevanssi and its live search plugin. There, I would like to display the category (if available) for each entry in the search results. For example

    word (dictionary)
    word / wohrd (common misspellings)

    Is there a (simple) way of putting this into practice? Ideally, of course, both in the normal search results and in the live search. But live search at least would be great, since this is mostly used on the site.

    Thanks in advance
    Tobias

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

    (@msaari)

    The live search results are powered by a normal WP search results template. You can customize the template, and including the category is simple. You can, for example, use the_category() to print a list of categories.

    The same goes with the main search results: you can control what is displayed by modifying the template. Relevanssi doesn’t have anything to do with that; it’s all controlled by your theme.

    Thread Starter Tobias

    (@tobiaseichner)

    Thanks alot. I’ll have a look at it.

    Tobias

    Thread Starter Tobias

    (@tobiaseichner)

    By the way, I used this code for the ajax-powered search in its template:

    	while ( have_posts() ) :
    the_post();
    ?>
    <div class="relevanssi-live-search-result" role="option" id="" aria-selected="false"><p><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?> <span class="small-search-cat"> <?php echo ' ('; foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; echo ')'; } ?></span> &raquo;</a></p></div><?php
    endwhile;

    Maybe someone finds it useful.

    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to include category names in search results?’ is closed to new replies.