This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to make the product ranking on the English page consistent with the product ranking on the Chinese page. The sorting is consistent on the homepage but varies when selecting a category to view products.
Solution:
To achieve consistent product order across languages, we recommend defining a secondary sorting condition. If sorting by SKU is your preferred method, you can add a custom code snippet to your theme's
functions.php
file. Here is the code you need:
function custom_modify_shop_query($query) { // Only modify the shop order if an order has not been specified //if ( !isset($_GET['orderby']) && !is_admin() && $query->is_main_query() && is_shop()) { if ( !is_admin() && $query->is_main_query() && (is_shop() || is_product_category() || is_product_tag()) ) { // Set meta_key so SKU ordering works $query->set('meta_key', '_sku'); // Set orderby to array: first by date, then by SKU $query->set('orderby', array( 'date' => 'DESC', 'meta_value' => 'ASC', )); } }
This code ensures that products are first sorted by date and then by SKU, applying across shop, category, and tag pages. Please check your staging site to confirm the sorting behaves as expected.
If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 18 replies, has 2 voices.
Last updated by 3 weeks, 4 days ago.
Assisted by: Bigul.