تخطي الملاحة

Open

Reported for: إضافة WPML Multilingual CMS 4.6.4

Topic Tags: Compatibility

Overview of the issue

When the Remove parent slugs option is enabled in the Rank Math SEO plugin with WooCommerce, it leads to a problem with the translation of product categories. If you switch to a secondary language from a product category page, it points to the untranslated category slug, leading to a 404 error page.

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open …/wp-content/plugins/seo-by-rank-math/includes/modules/woocommerce/class-permalink-watcher.php file.
  • Look for line 124.
  • Replace this code:
    $permalink_structure  = wc_get_permalink_structure();
    $category_base        = trailingslashit( $permalink_structure['category_rewrite_slug'] );
    $is_language_switcher = ( class_exists( 'Sitepress' ) && strpos( $link, 'lang=' ) );
    
  • With:
    $permalink_structure  = wc_get_permalink_structure();
    
    // WPML Workaround for compsupp-6895
    if ( class_exists('Sitepress') ) {
    	$args = array('element_id' => $term->term_id, 'element_type' => $taxonomy );
    	$term_language_info = apply_filters( 'wpml_element_language_details', null, $args );
    	$permalink_structure['category_rewrite_slug'] = apply_filters('wpml_translate_single_string', $permalink_structure['category_rewrite_slug'], 'WordPress', 'URL '.$taxonomy.' tax slug', $term_language_info->language_code );
    }
    
    $category_base        = trailingslashit( $permalink_structure['category_rewrite_slug'] );
    $is_language_switcher = ( class_exists( 'Sitepress' ) && strpos( $link, 'lang=' ) );
    

ترك رد

يُرجى البقاء في الموضوع والتزام الاحترام للآخرين. إذا كنت بحاجة إلى مساعدة بشأن المشكلات التي لا تتعلق بهذا المنشور، فاستخدم منتدى الدعم لبدء محادثة أو إرسال تذكرة.

يمكنك استخدام هذه العلامات:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>