Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the the filter below to filter related posts by author, I added an author ID to test but they are not filtering by author

add_filter( 'woocommerce_product_related_posts', 'woo_custom_attribute_filter' );
function woo_custom_attribute_filter( $q ) {

            array(
            'orderby'        => 'rand',
            'posts_per_page' => $limit,
            'post_type'      => 'product',
            'author'        => 2,
            'fields'         => 'ids',
            'meta_query'     => $meta_query,
            'tax_query'      => array(
                'relation'      => 'OR',
                array(
                    'taxonomy'     => 'product_cat',
                    'field'        => 'id',
                    'terms'        => $cats_array
                ),
                array(
                    'taxonomy'     => 'product_tag',
                    'field'        => 'id',
                    'terms'        => $tags_array
                )
            )
        );
    //print_r($q);
    return $q;
}
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

$q should contain the array:

add_filter( 'woocommerce_product_related_posts', 'woo_custom_attribute_filter', 10, 1 );
function woo_custom_attribute_filter( $q ) {
    $q = array( /* args here */ );
    return $q;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.