I want to fetch woocommerce product reviews by product id or anything else and want to display it in a template created by me.
In woocommerce/templates/single-product/tabs/tabs.php
If you run a print_r()
on $tabs
after it has been declared you'll see that a portion of the output is the following:
[reviews] => Array (
[title] => Reviews (3)
[priority] => 30
[callback] => comments_template
)
This means that the callback is the function: comments_template()
.
Since this function doesn't accept a $post_id
parameter, the would need to be called within the loop.
However, the function does accept a parameter of the template file to use, so to answer the OP's direct question of how to use a custom template file - you can use the function like so:
comments_template( string $file = '/comments.php', bool $separate_comments = false );
This ^ was taken directly from the codex