Correct search results from Relevanssi and Woocommerce

I am using Relevanssi with Woocommerce

I have selected product_variation to be indexed and this works really well except for the link in the search results page.

For example: [url removed, login to view]

Returns a link to a variation of a product with the SKU 600114

This: [url removed, login to view] is the result of searching for the SKU of the parent product of which the one above is a variation.

How do I change the URL in the first case to go to the parent product as the link at the moment goes to a non existent page.

[url removed, login to view]

The only changes I have made to Relevanssi are to force the SKU hits to display above the remainder of the hits.

Here is the code to do this in the [url removed, login to view] file

// Search filter to promote SKU returns above relevant returns

add_filter('relevanssi_hits_filter', 'sku_hits_first');

function sku_hits_first($hits) {

$sku_hits = array();

$everything_else = array();

global $wp_query;

foreach ($hits[0] as $hit) {

$sku = get_post_meta($hit->ID, '_sku', true);

if ($sku == $wp_query->query_vars['s']) {

$sku_hits[] = $hit;


else {

$everything_else[] = $hit;



$hits[0] = array_merge($sku_hits, $everything_else);

return $hits;


This is just above the code to edit and add the variable part number you helped me with.

Habilidades: PHP, WordPress

Veja mais: www search com au, www i force com, true results, searching in array in c,, search com au, search au, add product woocommerce, search results php, woocommerce filter product, woocommerce product link, woocommerce change product variation, search result woocommerce, woocommerce product display, wordpress filter search plugins, wordpress woocommerce search page, woocommerce page, woocommerce filter search, search result page, php global variable, woocommerce code, php page search, results page, woocommerce variable product, product add woocommerce

Acerca do Empregador:
( 15 comentários ) Brighton, Australia

ID do Projeto: #5125760

Concedido a:


Hired by the Employer

$30 USD em 1 dia
(29 Comentários)