I have declared a variable in my single.php
$title = 'myvar';
Can I get it in my comments.php without re-declaring it again?
I use this code to get the comments.php templage:
<? comments_template( '', true ); ?>
Ty
I have declared a variable in my single.php
$title = 'myvar';
Can I get it in my comments.php without re-declaring it again?
I use this code to get the comments.php templage:
<? comments_template( '', true ); ?>
Ty
You must be logged in to post a comment.
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:
You can use php session variables to utilize the myvar variable anywhere you want.