Deprecated: 関数 WP_Dependencies->add_data() がバージョン 6.9.0 から非推奨になった引数付きで呼び出されました。IE の条件付きコメントは、対応しているすべてのブラウザで無視されます。 in /home/artws/woo-japan.info/public_html/wp-includes/functions.php on line 6131

Deprecated: 関数 WP_Dependencies->add_data() がバージョン 6.9.0 から非推奨になった引数付きで呼び出されました。IE の条件付きコメントは、対応しているすべてのブラウザで無視されます。 in /home/artws/woo-japan.info/public_html/wp-includes/functions.php on line 6131
コンテンツへスキップ →

using-custom-attributes-in-menus

Managing custom attributes in WooCommerce menus and taxonomy archives

レイヤーナビに使用できる属性はカスタムタクソノミーであり、メニューに表示したり、属性別に商品を表示したりすることができます。これにはいくつかの作業が必要で、アーカイブを有効にする必要があります。

Register the taxonomy for menus

カスタム属性にタクソノミーを登録する際、WooCommerceは以下のフックを呼び出します:

$show_in_nav_menus = apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name);

So, for example, if your attribute slug was size you would do the following to register it for menus:

add_filter('woocommerce_attribute_show_in_nav_menus', 'wc_reg_for_menus', 1, 2);

function wc_reg_for_menus( $register, $name = '' ) {
if ( $name == 'pa_size' ) $register = true;
return $register;
}

Custom attribute slugs are prefixed with pa_, so an attribute called size would be pa_size

では、Appearance > Menusであなたの属性を使用してください。ただし、タクソノミータームへのリンクをクリックすると、デフォルトのブログスタイルになることにお気づきでしょう。

Create a template

商品を思い通りに表示するには、属性をテーマ化する必要があります。そのためには

  1. Copy woocommerce/templates/taxonomy-product_cat.php into your theme folder
  2. Rename the template to reflect your attribute – in our example we'd use taxonomy-pa_size.php

これで、カスタム属性のタクソノミー用語を表示するときに、このテンプレートが表示されるようになります。