Continue reading WooCommerce: Searching for orders

WooCommerce: Searching for orders

…WHERE customer_id = %d”, $order_stats->customer_id ) ); $content .= ‘ ‘ . $customer->first_name . ‘ ‘ . $customer->last_name; // Order meta, for example billing and shipping addresses. $meta = get_post_meta( $post->ID ); $meta = array_combine( array_keys( $meta ), array_column( $meta, ‘0’ ) ); $content .= ‘ ‘ . $meta[‘_billing_address_index’]; $content…….= ‘ ‘ . implode( ‘ ‘, $item_names ); // Total sum of the order. $order_stats = $wpdb->get_results( $wpdb->prepare( “SELECT * FROM {$wpdb->prefix}wc_order_stats WHERE order_id = %d”, $post->ID ) ); $content .= ‘ ‘ . $order_stats->total_sales; // Customer first and last name. $customer = $wpdb->get_results( $wpdb->prepare( “SELECT * FROM {$wpdb->prefix}wc_customer_lookup……) { $post_types[] = ‘shop_order’; return $post_types; } ); This is not enough, though. The order use custom statuses. You also need to allow these statuses with this code snippet: add_filter( ‘relevanssi_valid_status’, ‘rlv_add_status’ ); add_filter( ‘relevanssi_valid_admin_status’, ‘rlv_add_status’ ); function rlv_add_status( $status_array ) { $status_array[] = ‘wc-completed’; $status_array[] = ‘wc-pending’; return…

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 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