Continue reading 10Web Photo Gallery

10Web Photo Gallery

The Photo Gallery plugin from 10Web uses a shortcode to add photo galleries to posts and pages. By default, Relevanssi doesn’t index the gallery contents. Photo Galler only registers the shortcode in the front end, so when Relevanssi indexes pages in the admin context, Relevanssi only sees the shortcode, not the gallery contents. To fix…

Read more 10Web Photo Gallery 0 Comment on 10Web Photo Gallery
Continue reading Premium 2.19 / Free 4.17

Premium 2.19 / Free 4.17

…enable the feature with add_filter( ‘woocommerce_get_filtered_term_product_counts_query’, ‘relevanssi_filtered_term_product_counts_query’ ); Minor fix: Data attribute handling for in-document highlighting is now better. Version 2.19 / 4.17 Premium. New feature: New CLI command list_pinned_posts lists all pinned and unpinned posts. Premium. New feature: New CLI command list lists indexed and unindexed posts, taxonomy terms……and users. New feature: You can now look at how the posts appear in the database from the Debugging tab. New feature: Relevanssi now works with WooCommerce layered navigation filters. The filter post counts should now match the Relevanssi search results. Premium. New feature: You can now export the click……tracking logs. New feature: The new function relevanssi_count_term_occurrances() can display how often search terms appear in the database. Changed behaviour: Relevanssi post update trigger is now on wp_after_insert_post instead of wp_insert_post (for WP versions 5.6+). This makes the indexing more reliable and better compatible with other plugins. Changed behaviour: Throttling…

Read more Premium 2.19 / Free 4.17 0 Comment on Premium 2.19 / Free 4.17
Continue reading Search form: Search only in titles

Search form: Search only in titles

…everything that isn’t a title match. add_filter( ‘relevanssi_match‘, function( $match ) { if ( 1 === intval( $_GET[‘titles’] ) ) { if ( $match->title < 1 ) { $match->weight = 0; } } return $match; } ); This function will set the match weight to if the word doesn’t match…

Read more Search form: Search only in titles 0 Comment on Search form: Search only in titles
Continue reading YITH Badge Management

YITH Badge Management

The Premium version of YITH Badge Management has a search feature for badges. Using Relevanssi breaks that badge search. Fortunately, it’s easy to fix. Add this to your site: add_filter( ‘relevanssi_prevent_default_request’, ‘rlv_yith_badge_management’, 10, 2 ); add_filter( ‘relevanssi_search_ok’, ‘rlv_yith_badge_management’, 10, 2 ); function rlv_yith_badge_management( $do_stuff, $query ) { if ( ‘yith-wcbm-badge’…

Read more YITH Badge Management 0 Comment on YITH Badge Management
Continue reading Integrating Koko Analytics stats

Integrating Koko Analytics stats

It’s possible to integrate all kinds of external data to Relevanssi weights. Koko Analytics is a great analytics plugin. It collects stats about your visitors and stores them in the local database, which means those stats are available for Relevanssi. For some sites, this makes a lot of sense. For example, I have Kirjavinkit, a…

Read more Integrating Koko Analytics stats 0 Comment on Integrating Koko Analytics stats
Continue reading How to block searches without a search term

How to block searches without a search term

By default, Relevanssi returns all posts when searching without a search term. That’s the default WordPress behaviour. Sometimes it may not be the wanted behaviour. One reason is performance: returning all results can be very slow. To stop Relevanssi from running when there’s no search term, add this to your……site: add_filter( ‘relevanssi_search_ok’, function ( $ok, $query ) { if ( empty( $query->query_vars[‘s’] ) ) { $ok = false; } return $ok; }, 10, 2 ); This little function will stop Relevanssi from running when there’s no search term specified. It will still leave you with the default WordPress search……that returns all the posts. That’s generally faster than Relevanssi. If you don’t want anything returned when there’s no search term, add this function to stop even the default WP search: add_filter( ‘posts_request’, function( $request, $query ) { if ( $query->is_search() && $query->is_main_query() && !is_admin() && empty( $query->query_vars[‘s’] ) )…

Read more How to block searches without a search term 2 Comments on How to block searches without a search term
Continue reading German umlauts

German umlauts

By default, the search ignores German umlauts. Searching for “uber” will also find “über” and so on. This ignorance is not a Relevanssi feature but instead governed by your database. The default database collation WordPress uses (utf8mb4_unicode_ci) ignores all accents, including umlauts. If you want the search to care about…umlauts, you can change the collation. For German, use utf8mb4_german2_ci (actually, use utf8mb4_swedish_ci, see comments below): Now, the database will not ignore umlauts. Relevanssi also removes accents to match what the database does, so you must also undo that. Add this to your site: remove_filter( ‘relevanssi_remove_punctuation’, ‘remove_accents’, 9 ); Once…

Read more German umlauts 1 Comment on German umlauts
Continue reading Italian plurals

Italian plurals

$word = mb_substr( $word, 0, -3 ) . ‘ca’; } $end = mb_substr( $word, -1 ); if ( mb_strlen( $word ) > 3 && in_array( $end, array( ‘a’, ‘e’, ‘i’, ‘o’ ) ) ) { $word = mb_substr( $word, 0, -1 ); } $new_words[] = $word; } return implode( ‘……$string ) { $words = explode( ‘ ‘, $string ); $new_words = array(); foreach ( $words as $word ) { $end = mb_substr( $word, -3 ); if ( ‘ghe’ === $end ) { $word = mb_substr( $word, 0, -3 ) . ‘ga’; } if ( ‘che’ === $end ) {……’, $new_words ); }, 10, 9 ); This function checks each word, and if it ends with “ghe” or “che”, the ending is changed to “ga” or “ca”, respectively. Then if the word is over three letters long, a final “a”, “e”, “i”, or “o” is stripped. Now plural and…

Read more Italian plurals 3 Comments on Italian plurals
Continue reading Attachment file content cannot be saved

Attachment file content cannot be saved

The Relevanssi error “Could not save the file content to the custom field” means that Relevanssi has managed to read the attachment contents but cannot save them to the _relevanssi_pdf_content custom field Relevanssi uses to store the attachment contents. Relevanssi uses the update_post_meta() function to save the content, and for…

Read more Attachment file content cannot be saved 0 Comment on Attachment file content cannot be saved
Continue reading The Events Calendar: The event search

The Events Calendar: The event search

The event search from The Events Calendar does not work when Relevanssi is enabled. In regular use, it works, but if you try to access the event list directly with a search term in the URL, the search finds nothing. One solution is to make Relevanssi index the tribe_events post……function will stop Relevanssi from interfering with The Events Calendar search. There’s a bug in the current version of Relevanssi (2.18.0 for Premium, 4.16.0 for free version): if you have enabled Relevanssi in admin searches, the event search won’t work. Disable Relevanssi in admin searches to make the search function….…type. Then you can enable Relevanssi in the event search by adding this snippet to your site: add_action( ‘pre_get_posts’, function( $q ) { if ( isset( $q->query_vars[‘post_type’] ) && ‘tribe_events’ === $q->query_vars[‘post_type’] ) { $q->set( ‘relevanssi’, true ); } } ); This function will turn Relevanssi on in all searches…

Read more The Events Calendar: The event search 7 Comments on The Events Calendar: The event search