Continue reading WooCommerce: Searching for orders

WooCommerce: Searching for orders

orders: add_filter( ‘relevanssi_content_to_index’, ‘rlv_index_order_content’, 10, 2 ); function rlv_index_order_content( $content, $post ) { if ( ‘shop_order’ === $post->post_type ) { global $wpdb; // Order number. $content .= ‘ ‘ . $post->ID; // Product names. $item_names = $wpdb->get_col( $wpdb->prepare( “SELECT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d”, $post->ID ) ); $content…Searching for shop orders is tricky with WooCommerce. WooCommerce blocks searching the orders. WooCommerce also keeps the order data in many different tables. Because of this complexity, the shop_order post type is not available for indexing. You can enable it by adding this to your site: add_filter( ‘option_relevanssi_index_post_types’, function( $post_types……$status_array; } Now the orders are available in the Relevanssi admin search. They are still excluded from the front end search. Relevanssi indexes very little information about the order by default. You only get the order date. WooCommerce stores the items in the order in wp_woocommerce_order_items. Some stats about the…

Read more WooCommerce: Searching for orders 0 Comment on WooCommerce: Searching for orders
Continue reading Visual Composer: Indexing headings

Visual Composer: Indexing headings

Relevanssi doesn’t by default index the headings in Visual Composer. The vcex_heading shortcode Visual Composer for the headings stores the heading text inside a shortcode attribute. By default, Relevanssi does not index shortcode attributes. In this case, indexing the shortcode attribute is necessary. Fortunately, it’s easy to fix with a simple function added to your…

Read more Visual Composer: Indexing headings 0 Comment on Visual Composer: Indexing headings
Continue reading Search is ignoring accents

Search is ignoring accents

specific collations for individual columns, and we’re mostly interested in the specific collations for the term and term_reverse columns. If you change the collation to something that does not ignore accents, you also need to make Relevanssi keep the accents. Add this to your site: remove_filter( ‘relevanssi_remove_punctuation’, ‘remove_accents’, 9 );……these mixups (and also for the useful behaviour of ignoring accents). The reason is the MySQL database collation, which controls how the data is sorted and compared. The default collation for Relevanssi tables is utf8mb4_unicode_ci, which is a good, general-purpose collation. However, in some specific cases, it may be too……generic. Finnish (and Swedish) users may want to use utf8mb4_swedish_ci, which for example makes a and ä separate letters. You can adjust the collation in the database table settings, which you can modify with tools like phpMyAdmin or Adminer. There’s a general collation for the table and specific collations for…

Read more Search is ignoring accents 0 Comment on Search is ignoring accents
Continue reading Visual Composer: Indexing Raw HTML elements

Visual Composer: Indexing Raw HTML elements

Visual Composer and WP Bakery have a Raw HTML element that can be used to add HTML code to your pages. By default, this content is stored in an encoded format Relevanssi can’t read. Fortunately, the encoding is simple Base64 encoding that is easy to read. So, in order to read the contents of the…

Read more Visual Composer: Indexing Raw HTML elements 0 Comment on Visual Composer: Indexing Raw HTML elements
Continue reading Support for ^ and $ anchoring operators

Support for ^ and $ anchoring operators

In regular expressions, ^ can be used to match the beginning of the line and $ to match the end of the line. For example, ^ban will match banana, but not urban, while ban$ matches urban, but not banana. These are called anchoring operators. By default, Relevanssi matches either beginning or the end of the…

Read more Support for ^ and $ anchoring operators 0 Comment on Support for ^ and $ anchoring operators
Continue reading FacetWP

FacetWP

…are not available. Here’s a code snippet that can be used within FacetWP templates to generate and display Relevanssi excerpts for the posts: $query = isset( FWP()->facet->facets[‘search’] ) ? FWP()->facet->facets[‘search’][‘selected_values’] : ”; echo relevanssi_do_excerpt( $post, $query ); Using relevanssi_do_query filter functions with FacetWP There may be occasions where you need…

Read more FacetWP 0 Comment on FacetWP
Continue reading Metabox

Metabox

…global $wpdb; $table = $wpdb->prefix . ‘mb_relationships’; $author_ids = $wpdb->get_col( $wpdb->prepare( “SELECT `to` FROM $table WHERE `from` = %d AND type = ‘book-author'”, $post->ID ) ); foreach ( $author_ids as $author_id ) { $author_post = get_post( $author_id ); $content .= ‘ ‘ . $author_post->post_title; } } return $content; } What…Metabox is a suite of plugins to handle custom fields. It seems like a solid competitor for Advanced Custom Fields. There’s nothing particularly Relevanssi-unfriendly about it, since it uses custom fields to store the data and Relevanssi can read custom fields. MB Relationships MB Relationships is an extension to Metabox……that can be used to create relationships between posts. If you are interested in indexing these related posts somehow, that does require extra steps since the relationships data is stored in a separate database table. Let’s assume we have books (custom post type book) and each book has a number…

Read more Metabox 0 Comment on Metabox
Continue reading Modifying the search form on the fly

Modifying the search form on the fly

I set up a short coded search box to search my Learndash e-course for one specific category only: [ searchform ld_topic_category=”156″ ] It works perfectly except one thing: if no results show, it takes you to the default WordPress page and presents you with the standard search box that no longer searches category 156. This…

Read more Modifying the search form on the fly 0 Comment on Modifying the search form on the fly