• Hello,

    I would like to pass a user name as a parameter to my shop URL (example: myshop.com/shop/?creator=user1) and then display the products created by user1 only.

    I suspect I could use add_action( "woocommerce_product_query", "functionToDoTheJob" ), but I’m stuck on how to modify the query.

    Any help appreciated! Thank you in advance!

    https://www.ads-software.com/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • Try the following function.

    add_action( 'woocommerce_product_query', 'my_custom_query_by_author', 10, 2 );
    function my_custom_query_by_author($q, $product){
    
      if( isset($_GET['creator']) && $_GET['creator'] != '' ){
        $q->set('author', $_GET['creator']);
      }
    
    }

    Let me know how it goes.

Viewing 1 replies (of 1 total)
  • The topic ‘Archive products by creator’ is closed to new replies.