2016-11-11 8 views

答えて

1

あなたは、製品の属性にpa_するのではなく、あなたのURLでカスタムベースを使用することができる機能は、もはやWooCommerceで標準装備されていません。

商品のURLを希望する拠点にタクソノミのパーマリンクを設定していることを確認する必要があります。 WordPress Dashboard> Settings> Permalinkメニューに入ると、カテゴリ、用語、属性を製品に最も合ったものに変更できます。これらの設定を変更することで、製品にカスタムベースを使用することができます(タクソノミー内でベースを繰り返さないようにしてください。これにより競合が発生します)。

次に、あなたのテーマののfunctions.phpファイルに次のコードを追加する必要があります。このことができます

// Change attribute rewrite rules 
add_action('woocommerce_register_taxonomy', 'razorfrog_woo_register_taxonomy'); 
function razorfrog_woo_register_taxonomy() { 
    global $razorfrog_woo_attribute_labels; 
    $razorfrog_woo_attributes_labels = array(); 

    if ($attribute_taxonomies = wc_get_attribute_taxonomies()) { 
     foreach ($attribute_taxonomies as $tax) { 
      if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) { 
       $razorfrog_woo_attribute_labels[ $tax->attribute_label ] = $tax->attribute_name; 
       add_filter('woocommerce_taxonomy_args_'.$name, 'razorfrog_woo_taxonomy_args'); 
      } 
     } 
    } 
} 

function razorfrog_woo_taxonomy_args($taxonomy_data) { 
    global $razorfrog_woo_attribute_labels; 

    if (isset($taxonomy_data['rewrite']) && is_array($taxonomy_data['rewrite']) && empty($taxonomy_data['rewrite']['slug'])) { 
     $taxonomy_data['rewrite']['slug'] = $razorfrog_woo_attribute_labels[ $taxonomy_data['labels']['name'] ]; 
    } 
    return $taxonomy_data; 
} 

希望を!

+0

woocommerceファイルを編集して属性のpa_を変更する方法はありますか?私はそれを私の子どもに含める。 –

+0

申し訳ありません、George!私はWooCommerceの2.3版以降、分類学の設定でベースを編集できないことに気付きました。私はあなたの子供のテーマ内のfunctions.phpファイルに追加する必要があるコードを追加しました。それがうまくいくこと! –

+0

このコードはpa_を削除していますか? –

関連する問題