Continue reading Wishlist Member: Sorting the posts by membership levels

Wishlist Member: Sorting the posts by membership levels

…that posts on the specific Wishlist Member level * are first in the results. * * @param array $hits Contains the posts in $hits[0]. * * @return array The $hits array, filtered. */ function rlv_free_posts_first( $hits ) { $free_posts = array_filter( $hits[0], ‘rlv_free_filter’ ); $other_posts = array_udiff( $hits[0], $free_posts, ‘rlv_id_comparison’……level of one post. There’s a function that will get all the posts on a particular level, though, so we need to come up with a method to get the list once, then use it to check each individual post. The relevanssi_hits_filter function is simple: it uses array_filter()to get the……target posts from the list of all search results, then array_udiff() to get the rest of the posts and then array_merge() to merge the list back together in the correct order. The filter function for array_filter() calls a function that will return a list of post IDs for the target…

Read more Wishlist Member: Sorting the posts by membership levels 0 Comment on Wishlist Member: Sorting the posts by membership levels
Continue reading Premium 2.6 / Free 4.5

Premium 2.6 / Free 4.5

…automatic update. The download page shows two different versions of the plugin available. The basic version no longer includes tests or anything else you won’t need when actually using the plugin. The developer version includes tests and all sorts of other tooling you may find interesting if you’re a developer….

Read more Premium 2.6 / Free 4.5 5 Comments on Premium 2.6 / Free 4.5
Continue reading Partial matches to just one custom field

Partial matches to just one custom field

Is it possible to set (with filters and/or actions/functions) Relevanssi to use whole words keyword matching for post titles and 2 custom fields, and partial keyword matching only for a specific custom field (sku in this case)? Indeed it is! That is, you can’t set different keyword matching methods to different parts of the post,…

Read more Partial matches to just one custom field 0 Comment on Partial matches to just one custom field
Continue reading Excluding old content from the search

Excluding old content from the search

…* Adds a date filter to the search query. * * @param WP_Query $query The query object. * * @return WP_Query The modified query object. */ function rlv_date_filter( $query ) { $date_query = array( ‘after’ => ‘January 1st, 2016’, ‘inclusive’ => true, ); $query->set( ‘date_query’, $date_query ); return $query; }……news post type that are older than one year, you can use: add_filter( ‘relevanssi_indexing_restriction’, ‘rlv_exclude_old_news’ ); function rlv_exclude_old_news( $restriction ) { $restriction[‘mysql’] .= ‘ AND ( ( post.post_date >= CURDATE() – INTERVAL 1 YEAR ‘ . ” AND post.post_type = ‘news’ ) OR ( post.post_type != ‘news’ ) ) “;……$restriction[‘reason’] .= ‘ News post too old’; return $restriction; } If, on the other hand, you only want to apply this filter in searching, you can use the WP_Query date parameters like this: add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_date_filter’ ); /** * Adds a date filter to the search query. * * @param…

Read more Excluding old content from the search 2 Comments on Excluding old content from the search
Continue reading Restrict search by author from the search query

Restrict search by author from the search query

…of how you can optimize and cache using the transients. If you have a very stable list of authors, it’s not a bad idea to remove the whole affair with wp_list_authors() and the transients, and instead just list all the authors you want to include directly as the $authors array….…small lesson in the power of caching here as well. Notice the $author_list is taken from a transient, and only if it doesn’t exist, it’s generated with wp_list_authors(). The transient is stored for a week – because in most cases the list of authors is fairly stable – so the……function needs to be called just once per week. Why is this? I noticed in my tests that adding that one function call – just a single function – actually generated 200 database queries. A search without the user filter generated ~50 queries, a search with the filter did ~250 queries….

Read more Restrict search by author from the search query 0 Comment on Restrict search by author from the search query
Continue reading Target specific part of the post

Target specific part of the post

Relevanssi Premium 2.4.4 introduced a new feature where you can target specific parts of the post straight from the search terms. The format for this is {target:search_term} Target can be one of the following: title: Post title. content: Post content. author: Author display name. comment: Comment text. link: Link from…specifier for each word separately. Phrases are supported. Examples: Search for word “cat” in titles only: {title:cat} Search for word “dog”, but only in tags: {tag:dog} Search for posts that have the word “knizia” in the taxonomy “designers” and the word “dutrait” in the taxonomy “illustrators”: {designers:knizia} {illustrators:dutrait} Note that…

Read more Target specific part of the post 3 Comments on Target specific part of the post
Continue reading Premium 2.4.3

Premium 2.4.3

Relevanssi Premium 2.4.3 is a bug fix release that fixes two rather nasty bugs in 2.4.2. Bug fixes Disabling update_post_metadata_cache seemed like a good optimization move for related posts, but it turns out it also disables related posts thumbnails. We’ll take weaker performance with working images, so that optimization move has now been revoked. Importing…

Read more Premium 2.4.3 0 Comment on Premium 2.4.3