This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'relevanssi_stemmer', 'suomi_stemmer' ); | |
| function suomi_stemmer( $merkkijono ) { | |
| $stemmer = new FinnishStemmer(); | |
| return $stemmer->process( $merkkijono ); | |
| } | |
| class FinnishStemmer { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| remove_filter( 'relevanssi_hits_filter', 'relevanssi_wpml_filter' ); | |
| add_filter( 'relevanssi_hits_filter', 'creative_wpml_filter' ); | |
| function creative_wpml_filter( $data ) { | |
| $filtered_hits = array(); | |
| foreach ( $data[0] as $hit ) { | |
| if ( is_integer( $hit ) ) { | |
| // In case "fields" is set to "ids", fetch the post object we need. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add these to theme functions.php and go save the pages. | |
| add_filter( 'relevanssi_content_to_index', 'rlv_langwitch_elements', 10, 2 ); | |
| function rlv_langwitch_elements( $content, $post ) { | |
| $elements = get_option( '_alt_langwitch_elements_opts_page_' . $post->ID ); | |
| $element_content = ''; | |
| foreach ( $elements as $item ) { | |
| $value = rlv_process_array( $item ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Instructions: | |
| // 1. Remove the stopwords you want to enable in titles from the stopword list. | |
| // 2. List them in the function below. | |
| // 3. Add these functions to the theme functions.php. | |
| // 4. Rebuild the index. | |
| add_filter( 'relevanssi_index_titles', 'rlv_remove_stopwords' ); | |
| function rlv_remove_stopwords( $index_titles ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add this to theme functions.php and rebuild the index: | |
| add_filter('relevanssi_punctuation_filter', 'rlv_handle_slashes' ); | |
| function rlv_handle_slashes( $replacements ) { | |
| $replacements['/'] = ''; | |
| return $replacements; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add this to theme functions.php | |
| add_filter( 'relevanssi_hits_filter', 'rlv_category_sort' ); | |
| function rlv_category_sort( $hits ) { | |
| $gold = array(); | |
| $silver = array(); | |
| $bronze = array(); | |
| $everything_else = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add this to theme functions.php. | |
| add_filter( 'relevanssi_match', 'rlv_woo_stocklevel' ); | |
| function rlv_woo_stocklevel( $match ) { | |
| $in_stock = true; | |
| if ( has_term( 'outofstock', 'product_visibility', $match->doc ) ) { | |
| // Product is not in stock. | |
| $in_stock = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Adds the post slug to the post content, with dashes replaced with spaces. | |
| * Add this to theme functions.php and rebuild the index. | |
| * | |
| * @param string $content The additional post content. | |
| * @param object $post The post object. | |
| */ | |
| add_filter( 'relevanssi_content_to_index', 'rlv_index_slug', 10, 2 ); | |
| function rlv_index_slug( $content, $post ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Adds the post slug to the post content, with dashes replaced with spaces. | |
| * Add this to theme functions.php and rebuild the index. | |
| * | |
| * @param string $content The additional post content. | |
| * @param object $post The post object. | |
| */ | |
| add_filter( 'relevanssi_content_to_index', 'rlv_index_slug', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // First, make sure user profiles are indexed with the meta fields. | |
| // Here's how you run the search. Get the search terms from wherever and place them in $search_terms. | |
| $args = array( | |
| 's' => $search_terms, | |
| 'post_types' => 'user', | |
| 'posts_per_page' => 10, |