Show product content from different language WPML, without duplication
-
Hello, I am using your plugin and WPML.
I have product title in English :
BravoProdigy Impact Dot Peen Module
and in Arabic:
??? ??? ?? ????? ?????? ?????My Relevanssi settings is WPML Limit results to current language. enabled
there is any way to ” If user was in English language, and he searched for ” ??? ” the product appear in search results ?
same if was in Arabic language , if he searched for “Dot peen” for examplethe issue, i can’t disable the option ” Limit results to current language. ” because i will start getting duplicate results if a product has same name in English and Arabic
I tried this code, but not able to achieve my goal
add_filter( 'relevanssi_content_to_index', 'rlv_index_titles', 10, 2 ); function rlv_index_titles( $content, $post ) { if ( 'product' === $post->post_type ) { $args = array( 'post_parent' => $post->ID, 'post_type' => 'product', 'posts_per_page' => -1 ); $products = get_posts( $args ); if ( ! empty( $products ) ) { foreach ( $products as $product ) { $arabic_product_id = apply_filters( 'wpml_object_id', $product->get_id(), 'product', false, 'ar' ); $arabic_product = wc_get_product( $arabic_product_id ); $arabic_title = $arabic_product->get_title(); $english_product_id = apply_filters( 'wpml_object_id', $product->get_id(), 'product', false, 'en' ); $english_product = wc_get_product( $english_product_id ); $english_title = $english_product->get_title(); $content .= " $arabic_title"; $content .= " $english_title"; } } } return $content; }
do you have any suggestions ?
- The topic ‘Show product content from different language WPML, without duplication’ is closed to new replies.