2013-11-20 4 views
0

WooCommerce는 제품 페이지에 표시된 관련 제품 수를 변경하는 방법에 대해 documentation을 제공합니다. 변경하는 방법이 있습니까 과 관련이 있습니까? 현재 카테고리별로 관련이있는 것 같습니다. 단일 속성을 기반으로 관련 제품을 표시하는 방법이 있습니까? 다음은속성별로 관련 제품을 표시하는 방법 - WooCommerce

필터 : 타겟팅하려는 속성이 'woocommerce_attributes', 테스트하지하지만 이것이다

<?php 
/** 
* WooCommerce Extra Feature 
* -------------------------- 
* 
* Change number of related products on product page 
* Set your own value for 'posts_per_page' 
* 
*/ 
function woo_related_products_limit() { 
    global $product; 

    $args = array(
     'post_type'    => 'product', 
     'no_found_rows'   => 1, 
     'posts_per_page'  => 6, 
     'ignore_sticky_posts' => 1, 
     'orderby'    => $orderby, 
     'post__in'    => $related, 
     'post__not_in'   => array($product->id) 
    ); 
    return $args; 
} 
add_filter('woocommerce_related_products_args', 'woo_related_products_limit'); 

답변

1

당신은 wp_query의 분류 기능을 통해 그것을 할 수 있어야 ... link

작동해야 함 :

$args = array(
    'post_type'    => 'product', 
    'no_found_rows'   => 1, 
    'posts_per_page'  => 6, 
    'ignore_sticky_posts' => 1, 
    'orderby'    => $orderby, 
    'post__in'    => $related, 
    'post__not_in'   => array($product->id), 
    'woocommerce_attributes' => 'attribute_slug', 
); 
return $args; 
관련 문제