Skip to content

Instantly share code, notes, and snippets.

@kharissulistiyo
Last active November 18, 2015 01:30
Show Gist options
  • Save kharissulistiyo/b579d50e70084663d0f8 to your computer and use it in GitHub Desktop.
Save kharissulistiyo/b579d50e70084663d0f8 to your computer and use it in GitHub Desktop.
WooCommerce Product Query by Author
<?php
add_action( 'woocommerce_product_query', 'my_custom_query_by_author', 10, 2 );
function my_custom_query_by_author($q, $product){
$author = $_GET['creator']; // Author ID param
if( isset($author) && $author != '' ){
$q->set('author', $author);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment