how ordering by ID not randomize related product of Woocommerce
-
Woocommerce display in single product page by default a section of correlated product, it retrieve in random mode 4 product with same category or tag.
So every time you reload the page or visit the page in next day it display every time different correlated product, this is not good option for SEO, because in this way not pass link juice between pages during the time.
so i want to try to display a correlated product by sequential ID order.
from what I understand woocommerce extrapolates related products randomly through the use of the orderby = ‘rand’ function in the query
then tried to find a filter that could change this value in orderby = ‘ID’ or orderby = ‘post__in’ , using this snippet in function.php of theme:
add_filter('woocommerce_output_related_products_args', 'wh_related_products_args'); function wh_related_products_args($args) { $args['orderby'] = 'ID'; // or $args['orderby'] = 'post__in'; return $args; }
but it does not work
what am I doing wrong ?
- The topic ‘how ordering by ID not randomize related product of Woocommerce’ is closed to new replies.