• Resolved Nickness

    (@nickness)


    Hi,

    I found that the taxonomy import is maybe missing something. From what I saw in WPML code (v3.1.5) the query they use to retrieve taxonomy translations is something like this :

    SELECT t.translation_id, t.language_code, t.element_id, t.source_language_code, NULLIF(t.source_language_code, ”) IS NULL AS original, tm.name, tm.term_id, COUNT(tr.object_id) AS instances
    FROM wp_icl_translations t
    LEFT JOIN wp_term_taxonomy tt ON t.element_id=tt.term_taxonomy_id
    LEFT JOIN wp_terms tm ON tt.term_id = tm.term_id
    LEFT JOIN wp_term_relationships tr ON tr.term_taxonomy_id=tt.term_taxonomy_id
    WHERE 1
    AND t.trid=’2217′
    GROUP BY tm.term_id

    So as you can see, the element_id value stored within wp_icl_translations is the term_taxonomy_id and not the term_id. So if term_id and term_taxonomy_id mismatch for some terms the method used by WPML To Polylang to import taxonomy can lead to some erroneous matching…

    So to fix that I just add these two lines within the specific elseif code for tax within process_post_term_translations()

    $termtax = $wpdb->get_results(“SELECT * FROM {$wpdb->prefix}term_taxonomy WHERE term_taxonomy_id = {$r->element_id}”);
    $r->element_id = $termTax[0]->term_id;

    Best regards

    https://www.ads-software.com/plugins/wpml-to-polylang/

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WPML Taxonomy Import is maybe missing something?’ is closed to new replies.