I am a great fan of Elastic Search, the ElasticPress plugin and the ElasticPress WooCommerce module. The other day, when I was working on a clients WooCommerce shop, it was the first time I wasn’t satisfied with the quality of the search results, though.

After some digging with the Debug bar and its ElasticPress extension, I could narrow down the problem to a combination of many resembling titles in our database and the Elastic Search fuzziness parameter. Of course the fantastic folks at 10up provide a filter for that in their ElasticPress plugin.

 

So here is how to disable fuzziness in the search:

function themeslug_deactivate_ep_fuzziness( $fuzz ) {
    return 0;
}
add_filter( 'ep_fuzziness_arg', 'themeslug_deactivate_ep_fuzziness' );

Of course you can even raise the fuzziness with the same method. If you want to adjust fuzziness dependent on other search parameters, the filter provides two more arguments, $search_fields and $args, which might help.

Recommendation: If you want to use WordPress with ElasticSearch, you can get both with Kinsta. Read more on how to speed up WordPress with their ElasticSearch solution on the Kinsta blogg.

 

	function my_related_posts_thumbnail( $title, $post, $instance ) {
		if ( has_post_thumbnail( $post->ID ) ) {
			$title = get_the_post_thumbnail($post->ID).$title;
		}
		return $title;
	}
	add_filter( 'simply_related_posts_title', 'my_related_posts_thumbnail', 10, 3 );

The Snippets Story

If you are using my Simply related Posts plugin, you might want to have related post thumbnails. The code above is simply adding the post-thumbnail before the related post titles, if it exists. It implements the simply_related_posts_title filter, to add thumbnails to the printed title. Of course, you can add not only thumbnails, but any other kind of information to the title, by using that filter.

Works with version Simply related Posts 1.2 and later.

Update: Simply Related Posts 1.3 comes with a Serbian tanslation! Thanks to Borisa Djuraskovic from http://www.webhostinghub.com!

I’ve just released Simply Related Posts 1.2, a new version of my Simply Related Posts plugin. Now it supports pages, attachment-pages and custom post-types, which makes it a lot more flexible. Additionally I’ve added a filter to the related post-title, so you can add thumbnails, excerpts or anything else you can think of.

Test Simply Related Posts 1.2 now, download it from the plugin directory.

As always, post your questions, feedback etc. here below in the comments section!

Color Scheme every Theme 2.0 (read about v1.o here) makes it even more easy to create color schemes for WordPress themes.

Get version 2.0 on wordpress.org

After the release of version 1.0, some bug-fixing and the release of two minor versions I had got so much feedback that I thought it was time to implement the two feature requests most users suggested:

  • Editing color schemes directly in the admin interface, instead of having to add code in the functions.php
  • An option to make the css for all schemes available in the theme, to make it possible to change the scheme not only via the admin interface, but even on the front-end.

This resulted in a completely new options page, see a screenshot below:

screenshot-2

Here you got the possibility to edit the scheme directly in the admin interface. Just click on a color and change it in the Change color input field, hit enter, pick the next color you want to change. Don’t forget to save the schemes when you are done.

If you want to use the Dynamic theme colors option and used version 1.0 of the plugin, you have to regenerate the schemes.

There is still the possibility to permanently add a scheme to your theme by copying it to the functions.php of that theme. If you want to do that, just create the new theme via the admin interface, save and click on the < embed in theme > link, which opens an textarea with the code you have to add in it.