WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Search hit highlighting messes URL links (7 posts)

  1. Andrzej
    Member
    Posted 1 year ago #

    It appears that search terms that appear in an 'href' URL are replaced by the HTML 'strong' tag making the URL dis-functional. Has anyone else has seen this issue or could it be that my Relevanssi settings need tweaking. I don't see an option to disable URL highlighting.

    In my case, a page has a URL link where the link name is also the URL.

    Thanks for all suggestions.

    http://wordpress.org/extend/plugins/relevanssi/

  2. Whitegoodshelp
    Member
    Posted 1 year ago #

    I have exactly the same problem -

    I've just started using Relevanssi Search and it's great. I will almost certainly upgrade to the paid for version. However, I have a bug to fix first.

    When I configure search to highlight query terms, if any graphic on a relevant page contains the search query term in its name it does not display. For example, on my blog I search for TOC, and there is 1 page in the results, this page contains a graphic called TOC.png which no longer displays.

    This seems to be because Relevanssi changes the name of the graphic in order to try and highlight it. The graphic is here -
    http://www.whitegoodshelp.co.uk/wordpress/wp-content/uploads/2013/02/TOC.png

    But on the search results page the link is changed to a none existent -
    http://www.whitegoodshelp.co.uk/wordpress/wp-content/uploads/2013/02/%3Cspan%20style='background-color:%20#ffaf75'>TOC</span>.png

    I've replicated this fault on other pages, and it only seems to affect any image with a name containing the searched for term.

  3. Andrzej
    Member
    Posted 1 year ago #

    After some poking around in the Relevanssi excerpts-highlights.php file, I found a temporary workaround.

    - just after line 339: get_option('relevanssi_word_boundaries', 'on')...
    - add: $word_boundaries = false;

    Alternately, in the settings area, uncheck: Uncheck this if you use non-ASCII characters. I haven't tried this setting but the source code shows that this option controls 'word_boundaries', which may also affect the image link modification.

  4. wpmnger
    Member
    Posted 1 year ago #

    This may have something to do with 'Create custom search result snippets' option. Do you have that checked? It makes for nicer search results but can also mess things up if you have complex template files.

    If you don't want your image attachments turning up, you can uncheck 'attachment' from the 'indexing options'. Or use the Exclusions section to target individual attachments.

    I wouldn't rush to mess with the plugin files themselves... what if there is an update?

    Try using filters instead, check out this example of search filtering from the Relevanssi User Manual.

    I made a filter to to return only attachments which are Word Docs, excluding all other attachments:

    add_filter('relevanssi_hits_filter', 'exclude_attachments');
    function exclude_attachments($hits) {
    	$filtered = array();
    	foreach ($hits[0] as $hit) {
    		if($hit->post_type == 'attachment')
    		{
    			//Only keep attachments that are Word Documents
    			if ($hit->post_mime_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
    				array_push($filtered, $hit);
    			}
    
    		}
    		//Keep all results that are not attachments
    		else {
    			array_push($filtered, $hit);
    		}
    	}
    
    	$hits[0] = $filtered;
    	return $hits;
    }
  5. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    This was just fixed in version 3.1.6.

  6. Whitegoodshelp
    Member
    Posted 1 year ago #

    That's great news thanks :)

  7. Andrzej
    Member
    Posted 1 year ago #

    Mikko,

    Thank you so much for all the pathes and refinements. I have verified that the bold link issue has been resolved and everything is working nicely.

    -cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.