問題の概要
外観メニューでメニューを作成し、場所に割り当てた後、ページを更新すると、場所のチェックボックスのチェックが外れます。ただし、フロントエンドではメニューは引き続き正しく表示されます。
この問題は、タームIDがタームタクソノミーIDと等しくない場合に発生します。これは、こちら (新しいタブで開く)で説明されているように、バージョン4.1以前からWordPressを実行しているサイトで発生する可能性があります。
回避策
この問題はWPML 4.6.4で修正されました。 更新するとサイト上の問題は解決するため、この回避策が必要になるのは、まだ更新できない場合のみです。
続行する前に、必ずサイトの完全なバックアップを作成してください。
- …/sitepress-multilingual-cms/inc/taxonomy-term-translation/wpml-term-translation.class.phpを開きます。
- 118行目を探します。
- 変更前:
変更後:PHP
private function maybe_warm_term_id_cache() { if ( ! isset( $this->ttids ) || ! isset( $this->term_ids ) ) { $data = $this->wpdb->get_results( " SELECT wpml_translations.element_id, tax.term_id, tax.taxonomy " . $this->get_element_join() . " JOIN {$this->wpdb->terms} terms ON terms.term_id = tax.term_id WHERE tax.term_id != tax.term_taxonomy_id", ARRAY_A ); $this->term_ids = array(); $this->ttids = array(); foreach ( $data as $row ) { $this->ttids[ $row['term_id'] ] = isset( $this->ttids[ $row['term_id'] ] ) ? $this->ttids[ $row['term_id'] ] : array(); $this->ttids[ $row['term_id'] ][ $row['taxonomy'] ] = $row['element_id']; $this->term_ids[ $row['element_id'] ] = $row['term_id']; } } }
PHPprivate function maybe_warm_term_id_cache() { if ( ! isset( $this->ttids ) || ! isset( $this->term_ids ) ) { $data = $this->wpdb->get_results( " SELECT wpml_translations.element_id, tax.term_id, tax.taxonomy " . $this->get_element_join() . " JOIN {$this->wpdb->terms} terms ON terms.term_id = tax.term_id WHERE tax.term_id != tax.term_taxonomy_id", ARRAY_A ); $this->term_ids = array(); $this->ttids = array(); foreach ( $data as $row ) { $this->ttids[ $row['term_id'] ] = isset( $this->ttids[ $row['term_id'] ] ) ? absint($this->ttids[ $row['term_id'] ]) : array(); $this->ttids[ $row['term_id'] ][ $row['taxonomy'] ] = absint($row['element_id']); $this->term_ids[ $row['element_id'] ] = absint($row['term_id']); } } }