Continue reading Yoast Local SEO

Yoast Local SEO

Yoast Local SEO plugin breaks Relevanssi search. It enhances the search by adding meta queries. Unfortunately they don’t work with Relevanssi. The fix is simple, though. Add this to the theme functions.php: add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_meta_fix’, 99 ); function rlv_meta_fix( $q ) { $q->set( ‘meta_query’, array() ); return $q; }add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_meta_fix’, 99 ); function rlv_meta_fix(…

Read more Yoast Local SEO 14 Comments on Yoast Local SEO
Continue reading Adding a custom field filter in the search

Adding a custom field filter in the search

…! empty( $query->query_vars[‘colour’] ) ) { $meta_query = array( array( ‘key’ => ‘colour_field’, ‘value’ => $query->query_vars[‘colour’], ‘compare’ => ‘=’, ), ); $query->set( ‘meta_query’, $meta_query ); } return $query; } If you need to have multiple meta fields in the same search, you must add them to the same meta_query –……form): add_filter( ‘query_vars’, ‘rlv_add_qv’ ); function rlv_add_qv( $qv ) { $qv[] = ‘colour’; return $qv; } Then we need a function that reads in the query variable, formulates a meta_query and passes that to Relevanssi: add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_add_meta_query’ ); function rlv_add_meta_query( $query ) { if ( isset( $query->query_vars[‘colour’] ) &&……} If you need to have multiple meta fields in the same search, you must add them to the same meta_query – you can only have one. WP_Query documentation has a good example of what that looks like, so take a look at that if you need multiple custom fields….

Read more Adding a custom field filter in the search 48 Comments on Adding a custom field filter in the search
Continue reading Ordering search results by date

Ordering search results by date

I’m building a directory and would like the oldest posts to automatically display first in the search results, is this possible? I found out how to add a link that the user can click to sort the results but would like an automatic solution. Can you provide code that can be added to the functions.php…

Read more Ordering search results by date 3 Comments on Ordering search results by date
Continue reading Free 3.0

Free 3.0

…$wp_query before it is passed to Relevanssi. New filter: relevanssi_search_ok lets you adjust when search is enabled. New filter: relevanssi_pre_excerpt_content lets you adjust post content before excerpt creation. New filter: relevanssi_excerpt_content lets you adjust post content before excerpt creation, but after the_content. New filter: relevanssi_ellipsis lets you change the default……‘…’ in excerpts to something else. New filter: relevanssi_do_not_index is given a post ID and expects a boolean in return: should this post be indexed or not? New filter: relevanssi_match lets you meddle with the matching engine. New filter: relevanssi_results filters the result set from the search. New filter: relevanssi_content_to_index……need Relevanssi Premium, which does it better anyway. Relevanssi can handle certain whitespace characters better in indexing. Apostrophes are now replaced with whitespace instead of being removed. Relevanssi now shows correct number of results when posts_per_page is set to -1. Fuzzy search didn’t always activate when it should, if all…

Read more Free 3.0 32 Comments on Free 3.0