Continue reading ACF: Indexing files from File fields

ACF: Indexing files from File fields

Relevanssi can index attachment contents from files linked to posts with ACF File fields. This does not happen automatically but requires some extra code. The code required depends on which return value you use for your ACF File fields. If you use “File ID”, the code looks like this: add_filter(…

Read more ACF: Indexing files from File fields 1 Comment on ACF: Indexing files from File fields
Continue reading ACF: Filtering custom fields by type

ACF: Filtering custom fields by type

field type. Add this function to your site to restrict the custom field indexing to only “text” type fields: add_filter( ‘relevanssi_index_custom_fields’, function( $fields ) { $indexed_fields = array(); foreach( $fields as $field ) { $object = get_field_object( $field ); if ( is_array( $object ) && isset( $object[‘type’] ) && ‘text’…On sites where ACF fields are used a lot, with Flexible Content and Repeater fields, it may be difficult to make Relevanssi only index the relevant ACF fields. One way to deal with problem is to set Relevanssi to index “visible” custom fields and then restrict the indexed fields by…$fields as $field ) { $object = get_field_object( $field ); if ( is_array( $object ) && isset( $object[‘type’] ) && ‘text’ === $object[‘type’] ) { $indexed_fields[] = $field; } } return $indexed_fields; } ); To control which field types are included, modify the “if” clause to include more field types….

Read more ACF: Filtering custom fields by type 0 Comment on ACF: Filtering custom fields by type
Continue reading Ajax Load More

Ajax Load More

…of the extension, you can make Ajax Load More use Relevanssi by adding this function to your site: add_filter( ‘alm_modify_query_args’, function( $args ) { $args[‘relevanssi’] = true; return $args; } ); This function enables Relevanssi in the Ajax Load More queries. Every time Ajax Load More loads more results, it……counts as a new search for Relevanssi logs. If you don’t like that, you can make Relevanssi only log the first Ajax Load More search. If you want that, use these functions instead of the one above: add_filter( ‘alm_modify_query_args’, function( $args ) { global $rlv_is_offset_query; $args[‘relevanssi’] = true; if (…Ajax Load More is an infinite scrolling plugin for WordPress. It has a Relevanssi extension, but with the current versions of Ajax Load More (5.5.4.1 as I write this), the extension no longer does anything. The extension relies on a filter hook that does not exist in the plugin. Instead…

Read more Ajax Load More 0 Comment on Ajax Load More
Continue reading WPML: Indexing synced posts

WPML: Indexing synced posts

When a post is updated, WPML updates all the translations of the post, but Relevanssi only indexes the post that was updated, not the corresponding posts in other languages. This method hooks into save_post after WPML to tell Relevanssi also to index the matching translations. add_action( ‘save_post’, ‘index_post_in_all_languages’, 110, 2……); function index_post_in_all_languages( $post_ID, $post ) { if ( ! function_exists( ‘relevanssi_insert_edit’ ) ) { return; } $trid = apply_filters( ‘wpml_element_trid’, null, $post_ID, “post_{$post->post_type}” ); if ( ! $trid ) { return; } $translations = apply_filters( ‘wpml_get_element_translations’, null, $trid, $post->post_type ); foreach ( $translations as $lang => $translation ) {…

Read more WPML: Indexing synced posts 0 Comment on WPML: Indexing synced posts
Continue reading Polylang Pro: Indexing synced posts

Polylang Pro: Indexing synced posts

Polylang Pro has a feature to sync translations between posts. The problem with this and Relevanssi is that Relevanssi does not index the changes to the synced posts. With this filter function added to your site, Relevanssi will also index the synced posts: add_action( ‘save_post’, ‘index_post_in_all_languages’ ); function index_post_in_all_languages( $post_id……’slug’ ); $languages_to_index = array_diff( $all_languages, [ $post_language] ); foreach ( $languages_to_index as $lang ) { $post_id_to_index = pll_get_post( $post_id, $lang ); if ( $post_id_to_index > ) { relevanssi_insert_edit( $post_id_to_index ); } } } Thanks to Nico von Niederhäusern / Cubetech. There’s also a method for indexing WPML synced posts….

Read more Polylang Pro: Indexing synced posts 0 Comment on Polylang Pro: Indexing synced posts
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 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