0

I've added permissions to authors to add products in woocommerce. I would like to know if there is a way to display products by current user in archives.

Is this possible?

1

Use pre_get_posts to modify author archive queries-

function wpd_author_archive( $query ){
    if ( $query->is_author() && $query->is_main_query() ){
        $query->set( 'post_type', array( 'post', 'product' ) );
    }
}
add_action( 'pre_get_posts', 'wpd_author_archive' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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