• JD

    (@jutta0303)


    Hi Mikko,

    I use Relevanssi on 3 of my WordPress sites; 1. uses the “Zefir” theme (made by Envato), 2. uses the “Divi” theme (made by Elegant Themes), and 3. uses a theme called “Stack” (made by Themify).

    Relevanssi’s function to highlight search terms works fine on the first two sites, however none of the options for highlighting work on the third site. I’ve tried:
    –Highlight query terms in search results: <mark>
    –Highlight query terms in search results: <em>
    –Highlight query terms in search results: <strong>
    –Highlight query terms in search results: text color (with the color set in the box underneath)
    –Highlight query terms in search results: background color (with the color set in the box underneath)
    –Highlight query terms in search results: CSS style (with the styles set in the box underneath)
    –Highlight query terms in search results: CSS class (with the styles set in my custom CSS)

    None of theses options make any difference to my search terms. No <span> or <strong> tags get added in any of these cases.

    I disabled all plugins (except Relevanssi) and disabled my child theme, all to no avail. Still, the search terms do not get highlighted with any of the above options.

    I’d appreciate any help you can offer, Mikko.

    Thank you,
    Jutta Duncan

    • This topic was modified 8 years, 2 months ago by JD.
    • This topic was modified 8 years, 2 months ago by JD.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Mikko Saari

    (@msaari)

    What is the search results template in the third site using to print out the excerpts? Are you seeing Relevanssi-generated excerpts in the first place?

    Thread Starter JD

    (@jutta0303)

    No, I’m not seeing Relevanssi-generated excerpts at all. Just shows me the content of the posts that contain the search term.

    How do I find out what search results template this site is using to print out the excerpts?

    Thread Starter JD

    (@jutta0303)

    Hi Mikko,

    Actually, I just noticed that the Relevanssi-generated excerpts do seem to work, but only when I have a plugin called “Advanced Excerpts” turned on, and when I have my theme’s settings set so that by default only excerpts are shown instead of the full content of my post. I do not want either of these things (plugin or theme setting) however. So, what should I do.

    In either case though, the search terms still do not get highlighted.

    Plugin Author Mikko Saari

    (@msaari)

    What is the search results template in the third site using to print out the excerpts? Can you show me the search results template from the theme?

    If the theme is set to display full post content, that’s guaranteed not to work with Relevanssi. The theme needs to be set to use excerpts, and it still can do it in a way that doesn’t work with Relevanssi highlighting.

    • This reply was modified 8 years, 2 months ago by Mikko Saari.
    Thread Starter JD

    (@jutta0303)

    Themify told me that this is the search results template; in their words, “[Stack] Theme uses index.php as search template, it uses WP default search.”

    From the Stack index.php

    <?php
    /**
     * Template for common archive pages, author and search results
     * @package themify
     * @since 1.0.0
     */
    ?>
    <?php get_header(); ?>
    
    <?php 
    /** Themify Default Variables
     *  @var object */
    global $themify;
    ?>
    		
    <!-- layout -->
    <div id="layout" class="pagewidth clearfix">
    
    	<!-- content -->
        <?php themify_content_before(); //hook ?>
    	<div id="content" class="clearfix">
        	<?php themify_content_start(); //hook ?>
    		
    		<?php 
    		/////////////////////////////////////////////
    		// Author Page	 							
    		/////////////////////////////////////////////
    		if(is_author()) : ?>
    			<?php
    			global $author, $author_name;
    			$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    			$author_url = $curauth->user_url;
    			?>
    			<div class="author-bio clearfix">
    				<p class="author-avatar"><?php echo get_avatar( $curauth->user_email, $size = '48' ); ?></p>
    				<h2 class="author-name"><?php _e('About ','themify'); ?> <span><?php echo $curauth->display_name; ?></span></h2>
    				<?php if($author_url != ''): ?><p class="author-url"><a href="<?php echo esc_url( $author_url ); ?>"><?php echo esc_url( $author_url ); ?></a></p><?php endif; //author url ?>
    				<div class="author-description">
    					<?php echo wp_kses_post( $curauth->user_description ); ?>
    				</div>
    				<!-- /.author-description -->
    			</div>
    			<!-- /.author bio -->
    			
    			<h2 class="author-posts-by"><?php _e('Posts by','themify'); ?> <?php echo esc_html( $curauth->first_name ); ?> <?php echo esc_html( $curauth->last_name ); ?>:</h2>
    		<?php endif; ?>
    
    		<?php 
    		/////////////////////////////////////////////
    		// Search Title	 							
    		/////////////////////////////////////////////
    		?>
    		<?php if(is_search()): ?>
    			<h1 class="page-title"><?php _e('Search Results for:','themify'); ?> <em><?php echo get_search_query(); ?></em></h1>
    		<?php endif; ?>
    	
    		<?php
    		/////////////////////////////////////////////
    		// Date Archive Title
    		/////////////////////////////////////////////
    		?>
    		<?php if ( is_day() ) : ?>
    			<h1 class="page-title"><?php printf( __( 'Daily Archives: <span>%s</span>', 'themify' ), get_the_date() ); ?></h1>
    		<?php elseif ( is_month() ) : ?>
    			<h1 class="page-title"><?php printf( __( 'Monthly Archives: <span>%s</span>', 'themify' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'themify' ) ) ); ?></h1>
    		<?php elseif ( is_year() ) : ?>
    			<h1 class="page-title"><?php printf( __( 'Yearly Archives: <span>%s</span>', 'themify' ), get_the_date( _x( 'Y', 'yearly archives date format', 'themify' ) ) ); ?></h1>
    		<?php endif; ?>
    
    		<?php 
    		/////////////////////////////////////////////
    		// Category Title	 							
    		/////////////////////////////////////////////
    		?>
    		<?php if(is_category() || is_tag() || is_tax() ): ?>
    			<h1 class="page-title"><?php single_cat_title(); ?></h1>
    			<?php echo themify_get_term_description(); ?>
    		<?php endif; ?>
    
    		<?php 
    		/////////////////////////////////////////////
    		// Default query categories	 							
    		/////////////////////////////////////////////
    		?>
    		<?php if( !is_search() ): ?>
    			<?php
    			global $query_string;
    			query_posts( apply_filters( 'themify_query_posts_args', $query_string.'&order='.$themify->order.'&orderby='.$themify->orderby ) );
    			?>
    		<?php endif; ?>
    
    		<?php 
    		/////////////////////////////////////////////
    		// Loop	 							
    		/////////////////////////////////////////////
    		?>
    		<?php if (have_posts()) : ?>
    		
    			<!-- loops-wrapper -->
    			<div id="loops-wrapper" class="loops-wrapper <?php echo esc_attr( $themify->layout . ' ' . $themify->post_layout ); ?>">
    
    				<?php while (have_posts()) : the_post(); ?>
    		
    					<?php if(is_search()): ?>
    						<?php get_template_part( 'includes/loop' , 'search'); ?>
    					<?php else: ?>
    						<?php get_template_part( 'includes/loop' , 'index'); ?>
    					<?php endif; ?>
    		
    				<?php endwhile; ?>
    							
    			</div>
    			<!-- /loops-wrapper -->
    
    			<?php get_template_part( 'includes/pagination'); ?>
    		
    		<?php 
    		/////////////////////////////////////////////
    		// Error - No Page Found	 							
    		/////////////////////////////////////////////
    		?>
    	
    		<?php else : ?>
    	
    			<p><?php _e( 'Sorry, nothing found.', 'themify' ); ?></p>
    	
    		<?php endif; ?>			
    	<?php themify_content_end(); //hook ?>
    	</div>
        <?php themify_content_after(); //hook ?>
    	<!-- /#content -->
    
    	<?php 
    	/////////////////////////////////////////////
    	// Sidebar							
    	/////////////////////////////////////////////
    	if ($themify->layout != "sidebar-none"): get_sidebar(); endif; ?>
    
    </div>
    <!-- /#layout -->
    
    <?php get_footer(); ?>

    So, when the theme is set to show the full content of the posts, even then, there’s no way to highlight the search terms at all, is that right? The only way the search terms will be highlighted is when the theme is set to show post excerpts instead; but even then, it’s not guaranteed that the search terms will be highlighted?

    Correct me if I misunderstood and if there is indeed some way that Relevanssi search terms can get highlighted when using the “full content” option in the theme settings.

    Thanks for your help.

    Thread Starter JD

    (@jutta0303)

    Any thoughts on this, Mikko? Any help is very appreciated.

    Thank you!

    Plugin Author Mikko Saari

    (@msaari)

    You can get the theme to highlight the search terms, but it requires some changes in the /includes/loop-search.php file (or somewhere else, I don’t really know how the theme works). You’d need to create a child theme if you’re not already using one, then make some changes there to enable the highlighting.

    Relevanssi has a function called relevanssi_highlight_terms() you can use to highlight the content, you just need to pass the full post content through that.

    Thread Starter JD

    (@jutta0303)

    I’m not sure I understand. Can you clarify what needs to be done? I’m happy to contact my theme developers to get some help for which file needs to be edited. This theme doesn’t have a loop-search.php file.

    How would I “pass the full post content through” the relevanssi_highlight_terms(). I’m not that familiar with PHP, but happy to give new things a try.

    And basically you’re saying that some themes just aren’t fully compatible with the Relevanssi plugin, yes? And my theme seems to be one of those.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Search terms not being highlighted’ is closed to new replies.