Continue reading Using multiple custom taxonomies

Using multiple custom taxonomies

Usually WordPress supports one category, one tag and one taxonomy in the search, if you use the query variables to set the taxonomies. You can enter multiple taxonomies as parameters to the query, but only the first one is used. If you want to have multiple taxonomies involved, you need to build a tax_query. The…

Read more Using multiple custom taxonomies 52 Comments on Using multiple custom taxonomies
Continue reading WP e-Commerce

WP e-Commerce

WP e-Commerce is a popular shopping cart plugin for WordPress. This code by Alexander Gieg, added to functions.php for example, makes Relevanssi work better with WP e-Commerce. add_filter(’relevanssi_excerpt_content’,’wpsc_product_excerpt’,10,3); function wpsc_product_excerpt($content, $post, $query) { if ( ‘wpsc-product’ == relevanssi_get_post_type($post->ID) ) { $content = $post->post_content . ( !empty($post->post_excerpt) ? " $post->post_excerpt" : ” ); if ( ‘on’…

Read more WP e-Commerce 14 Comments on WP e-Commerce
Continue reading Using Relevanssi without a search term

Using Relevanssi without a search term

Version 1.7.3 introduces the possibility to use Relevanssi without a search term. This is useful when you have extra query arguments that can be used to narrow the search, but which would be useful without a search term present. This was originally implented for a restaurant search, where the users can search for restaurants based…

Read more Using Relevanssi without a search term 42 Comments on Using Relevanssi without a search term
Continue reading Separating posts by post type

Separating posts by post type

Using the relevanssi_hits_filter, it’s easy to separate the search results by post type. The basic idea is: first split the search results in separate arrays by post type, then merge then back to $hits[0] in the correct order. The order of search results within the types remains untouched in the process. More relevanssi_hits_filter examples in…

Read more Separating posts by post type 28 Comments on Separating posts by post type
Continue reading Relevanssi_post_ok filter

Relevanssi_post_ok filter

Versions 2.9.8 (free) and 1.5.13 (premium) added a new filter, relevanssi_post_ok, which can be used to add support for membership plugins where there is a need to restrict certain posts from certain users. By default, this filter calls relevanssi_default_post_ok(), which has built-in support for private posts, Role-Scoper and s2member. Add your own function, if you…

Read more Relevanssi_post_ok filter 3 Comments on Relevanssi_post_ok filter
Continue reading Modify excerpts with relevanssi_excerpt_content

Modify excerpts with relevanssi_excerpt_content

From free 2.9.1 and Premium 1.5.8, there’s a new filter that makes modifying the excerpts easier. The relevanssi_excerpt_content filter is run after the post content is run through the the_content filter and before any other cleanup is done. This is a good point to insert for example custom field content. The filter hook passes three…

Read more Modify excerpts with relevanssi_excerpt_content 35 Comments on Modify excerpts with relevanssi_excerpt_content
Continue reading Disabling title or content indexing

Disabling title or content indexing

If you want to prevent the indexing titles or post content for some reason, Relevanssi has couple of useful filters for that. The filters are called relevanssi_index_content and relevanssi_index_titles. These are simple true/false filters, so if you want to activate the filter, add a function that returns false, like this: add_filter( ‘relevanssi_index_content’, ‘__return_false’ ); That’s all. Replace…

Read more Disabling title or content indexing 60 Comments on Disabling title or content indexing
Continue reading Taxonomy archive search

Taxonomy archive search

This is a Premium feature and only applies when you index taxonomy terms. This does not apply in free Relevanssi. To include taxonomy pages (categories, tags, custom taxonomies) in the search, enable the option in the options page. There’s also the option to choose which taxonomies are included. Currently the title of the taxonomy is…

Read more Taxonomy archive search 49 Comments on Taxonomy archive search
Continue reading Custom weighing with relevanssi_match and relevanssi_results

Custom weighing with relevanssi_match and relevanssi_results

If you want to fine-tune the post weights, version 1.4.5 introduces a new hook for that. The relevanssi_match hook lets you modify the matches found for queries. It passes a match object, which has the post id ($match->doc), number of hits found in different parts of the post and the weight assigned to the post…

Read more Custom weighing with relevanssi_match and relevanssi_results 64 Comments on Custom weighing with relevanssi_match and relevanssi_results
Continue reading Search results breakdown by type

Search results breakdown by type

Do you want to have a breakdown of search results by post type? This could be used for example to show a list of post types like books, movies, albums on a review site, and make them links to limit the search results to that post type. This is fairly easy to do with the…

Read more Search results breakdown by type 31 Comments on Search results breakdown by type