The comments_template()
only accepts two parameters: $file
(string) and $separate_comments
(Boolean). So, it does not have a way to pass an arbitrary variable as a parameter.
The two methods I generally use are:
- Globalize the variable
- Wrap the variable inside a function that returns the data you want, and then call it wherever you need it.