Adding author option to [products] woocommerce shortcode


I am trying to modify the [products] shortcode usage:

What I am looking was passing the author id from short code e.g [products author=2] to the query.

With the reference of:

But the sample was a true/false parameter to trigger the $query_args change, seems it’s not exactly my goal. And the function below is the only part I can put into use.

function htdat_woocommerce_shortcode_products_query( $query_args, $attributes ) {       
$query_args = array(
   //Receive the id//'author'    => '1',
   'post_status'    => 'publish',
   'post_type'      => 'product',
   'post_per_page'      => 12,
  return $query_args;
add_filter( 'woocommerce_shortcode_products_query', 'htdat_woocommerce_shortcode_products_query', 10, 2 );

If anyone could help, thank you.

Cwkin7 8 months 2020-11-24T07:10:19-05:00 0 Answers 13 views 0

Leave an answer