Continue reading Indexing post slugs

Indexing post slugs

By default, Relevanssi does not index the post slug. It is, however, an easy thing to fix using the relevanssi_content_to_index filter hook. This function will read the post slug, replace the hyphens with spaces (so that indexing-post-slugs becomes “indexing post slugs”) and add the slug to the post content. Add this function to your site…

Read more Indexing post slugs 0 Comment on Indexing post slugs
Continue reading Flatsome

Flatsome

…query matches a variation SKU, the product permalink is replaced with the variation permalink: add_filter( ‘post_type_link’, ‘rlv_wc_variation_permalink’, 10, 2 ); function rlv_wc_variation_permalink( $permalink, $post ) { global $flatsome_live_search_query, $wp_query; if ( empty( $flatsome_live_search_query ) && isset( $wp_query->query_vars[‘s’] ) ) { $flatsome_live_search_query = $wp_query->query_vars[‘s’]; } if ( ‘product’ === $post->post_type &&……$query, $args, $defaults ) { global $flatsome_live_search_query; $flatsome_live_search_query = $args[‘s’]; $args[‘relevanssi’] = true; return get_posts( $args ); } This stores the search query in a global variable so that we can use it later elsewhere. Then we need a filter function to adjust the permalinks so that when the search……! empty( $flatsome_live_search_query ) ) { $variations = rlv_get_variation_ids( $post->ID ); if ( isset( $variations[ $flatsome_live_search_query ] ) ) { remove_filter( ‘post_type_link’, ‘rlv_wc_variation_permalink’, 10 ); return get_permalink( $variations[ $flatsome_live_search_query ] ); } } return $permalink; } function rlv_get_variation_ids( $product_id ) { $variation_ids = array(); $args = array( ‘post_parent’ => $product_id,…

Read more Flatsome 0 Comment on Flatsome
Continue reading Restricting the search for non-logged-in users

Restricting the search for non-logged-in users

There was an interesting support question: I have website with logged-in users as well as non-logged-in users. The logged-in user should be able to search through everything on the website, but the non-logged-in users should only be able to search the user profiles. Is it at all possible to differentiate…

Read more Restricting the search for non-logged-in users 3 Comments on Restricting the search for non-logged-in users
Continue reading Searching between dates

Searching between dates

…$from_date[‘month’], ‘day’ => $from_date[‘day’], ); } // Same for the “to” date. if ( $to_date && checkdate( $to_date[‘month’], $to_date[‘day’], $to_date[‘year’] ) ) { $before = array( ‘year’ => $to_date[‘year’], ‘month’ => $to_date[‘month’], ‘day’ => $to_date[‘day’], ); } // Create the date query array and add the parameter sets to it……) ) { $to_date = date_parse( $_GET[‘to’] ); } $after = null; $before = null; // If the “from” date checks as a valid date, create a parameter set for it. if ( $from_date && checkdate( $from_date[‘month’], $from_date[‘day’], $from_date[‘year’] ) ) { $after = array( ‘year’ => $from_date[‘year’], ‘month’ =>……searches: add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_date_between’ ); function rlv_date_between( $query ) { $from_date = null; $to_date = null; // Get the dates from parameters “from” and “to”, and parse to make sure they are dates. if ( isset( $_GET[‘from’] ) ) { $from_date = date_parse( $_GET[‘from’] ); } if ( isset( $_GET[‘to’]…

Read more Searching between dates 17 Comments on Searching between dates
Continue reading Gmedia photo gallery tags

Gmedia photo gallery tags

Gmedia photo gallery gives a false impression of working with Relevanssi, as you can see the gmedia_tag taxonomy appear in the list of taxonomies: However, if you try to index those tags, you’ll soon notice Relevanssi isn’t actually indexing them. That’s because Gmedia gallery doesn’t use that taxonomy for the tags. The tags are actually…

Read more Gmedia photo gallery tags 0 Comment on Gmedia photo gallery tags
Continue reading Blocking pre and code tags

Blocking pre and code tags

…$content = preg_replace( ‘#<pre.*?</pre>#mis’, ”, $content ); $content = preg_replace( ‘#<code.*?</code>#mis’, ”, $content ); return $content; } This will find all <pre> and <code> tags in posts and replace them and their contents with nothing, both when indexing and when building excerpts. This will immediately take effect for excerpts, and…If your posts have lots of programming code examples in <pre> and <code> tags, those might look pretty bad in the search results. A snippet of programming code isn’t usually a good excerpt, and if you use those tags purely for code snippets, they won’t likely contain significant search content,……either. Fortunately it’s easy to completely remove all <pre> and <code> tags and their content both in indexing and excerpt-building. All you need to do is to add the following code to your theme functions.php: add_filter( ‘relevanssi_post_content’, ‘rlv_pre_code’, 10 ); add_filter( ‘relevanssi_excerpt_content’, ‘rlv_pre_code’, 10 ); function rlv_pre_code( $content ) {…

Read more Blocking pre and code tags 0 Comment on Blocking pre and code tags
Continue reading GDPR Compliance

GDPR Compliance

…It’s not currently possible to disable the logging of user IDs. These are personal information, and need to be reported on your privacy policy, if you have search logging enabled. Relevanssi includes tools to remove data from the logs. If you use the WordPress privacy tools to remove user’s data…completely from the system, that will automatically remove all log entries with their user ID. Relevanssi can’t automatically remove log entries for searches users do when they are not logged in, as Relevanssi cannot connect IP address to user ID. Attachment indexing Relevanssi doesn’t share any information outside your server,…We have a privacy policy that covers your use of this web site and our customer data use. However, if you’re interested in how using Relevanssi affects the GDPR compliance of your own site, here we have answers for you. In general, Relevanssi doesn’t store any information about users and…

Read more GDPR Compliance 0 Comment on GDPR Compliance
Continue reading Debugging Relevanssi searching issues

Debugging Relevanssi searching issues

…restrictions involved? Look at the results add_filter( ‘relevanssi_results’, ‘rlv_check_results’ ); function rlv_check_results( $results ) { var_dump( $results ); exit(); } This should print out an array of ( post ID, post weight ) pairs. Does that match the number of results you expect to find? Look at the posts returned…Relevanssi has plenty of useful filter hooks you can use to debug problems. Here are some examples of how you can use the Relevanssi filter hooks to debug issues. Add the functions one at a time to your site and run a search to see results. First, try the Relevanssi……admin search. Before checking the filters, try the Relevanssi admin search (Dashboard > Admin search). Does that find the correct results? If it does, then the problem is likely with your theme. Use Query Monitor Query Monitor is a superb tool for debugging WordPress behaviour. It’s very useful for debugging…

Read more Debugging Relevanssi searching issues 11 Comments on Debugging Relevanssi searching issues