S
S
sergo5732021-08-05 11:53:12
PHP
sergo573, 2021-08-05 11:53:12

How to sort by large label match?

Good afternoon.
WOOCOMMERCE has a related.php file that displays related (similar) products on the product page, sorting is currently on:

global $product, $porto_settings, $porto_woocommerce_loop;

if ( empty( $product ) || ! $product->exists() ) {
  return;
}
$related = wc_get_related_products( $product->get_id(), $porto_settings['product-related-count'] );
if ( sizeof( $related ) === 0 || ! $porto_settings['product-related'] ) {
  return;
}

$args = apply_filters(
  'woocommerce_related_products_args',
  array(
    'post_type'           => 'product',
    'ignore_sticky_posts' => 1,
    'no_found_rows'       => 1,
    'posts_per_page'      => $porto_settings['product-related-count'],
    'orderby'             => 'rand',
        'tag__in'             => $tag_ids,  
    'post__not_in'        => array( $product->get_id() ),
  )
);

$products = new WP_Query( $args );

Those. shows similar products if there is a match in at least one tag.

What do you need?
How to make it so that products would be shown by a greater match of tags?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question