• Resolved joshivince

    (@joshivince)


    Hallo Mikko,

    thanks for this perfect search plugin. I like the statistics / analytics gatherer-function behind a lot and this was the main reason why I installed the plugin.

    I use WordPress 6.2.2 running Sydney Child theme. I installed your plugin “Relevanssi – A Better Search” together with “Relevanssi Live Ajax Search”.

    The Ajax Box with the live search suggestions were not direct below my form but I was able to fix this with CSS by using this code:

    .relevanssi-live-search-results {
    width: 650px !important; /* Setzt die Breite auf 650px */
    left: auto !important; /* Setzt die linke Position auf automatisch */
    top: auto !important; /* Setzt die obere Position auf automatisch */

    }

    I got that CSS info by ChatGPT as I am not very good in programming.

    However the live search suggestion-function does two things NOT:

    1.) It has no syntax highlighting
    2.) No excerpt appears

    I for sure set the option “Excerpt and highlights” to any different possibility but it will not work for me. I want to use “Background Color” to highlight my search terms…

    I can’t link my site as it’s a internal site with blocked internet. You may help me with this issue?

    Thanks a very lot in advance,
    Vincent from south Germany.

    • This topic was modified 1 year, 1 month ago by joshivince.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    The default template in Live Ajax Search only displays the title. If you want it to display excerpts, you need a template that includes the excerpt. You can find instructions for creating a custom template at the Live Ajax Search page. ChatGPT can probably tell you how to modify the template =D

    In the default template, the post is displayed like this:

    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(); ?> &raquo;
        </a></p>
      </div>
      <?php
    endwhile;

    To include the excerpt, you can use

    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(); ?> &raquo;
        </a></p>
        <p><?php the_excerpt(); ?></p>
      </div>
      <?php
    endwhile;

    Something like that. The excerpt should automatically have the highlights. If you want highlights in the titles, replace the_title() in the template with relevanssi_the_title().

    Thread Starter joshivince

    (@joshivince)

    Thank you very much. It works like a charm now.

    For the others if someone is interested:

    1.) I created a new folder in my child theme called “relevanssi-live-ajax-search”
    2.) I copied the template “search-results.php” there
    3.) I modified the code like mentioned above from Mikko and added the time stamp as well and a class to modify it with CSS:

    while ( have_posts() ) :
    		  the_post();
    		  ?>
    		  <div class="relevanssi-live-search-result" role="option" id="" aria-selected="false">
    			<p>
    			<span class="post-date"><?php echo get_the_date('j. F Y'); ?></span>:<br /> <!-- Hier füge ich den Datumsstempel hinzu -->
    			<a href="<?php echo esc_url( get_permalink() ); ?>"><b><?php relevanssi_the_title(); ?></b> &raquo;</a> 
    			<?php the_excerpt(); ?></p>
    		  </div>
    		  <?php
    	endwhile;

    ChatGPT not only helped me with the code, Mikko. At the very beginning, when I searched for plugins, ChatGPT recommended me your plugin according to my search terms and preconditions (beside 2 others).

    Perfect, I’m very very satisfied!

    Best,
    Vincent

    • This reply was modified 1 year, 1 month ago by joshivince. Reason: Mark as solved!
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Highlighting in Live suggestions not working’ is closed to new replies.