WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ) {

            'orderby'        => 'rand',
            'posts_per_page' => $limit,
            'post_type'      => 'product',
            'author'        => 2,
            'fields'         => 'ids',
            'meta_query'     => $meta_query,
            'tax_query'      => array(
                'relation'      => 'OR',
                    'taxonomy'     => 'product_cat',
                    'field'        => 'id',
                    'terms'        => $cats_array
                    'taxonomy'     => 'product_tag',
                    'field'        => 'id',
                    'terms'        => $tags_array
    return $q;
share|improve this question
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

Your Answer


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.