- Load template
your-theme/templates/cards/post.php
. Please note that global variable will be accessible in the template.
get_partial( 'templates/cards/post' );
- Load template
your-theme/templates/cards/post.php
and pass a local variable.
$var = 'Hello world';
get_partial( 'templates/cards/post', compact( 'var') );
In template, just use $var as normal:
echo $var;
- Load template
your-theme/templates/cards/post.php
and pass multiple local variables.
$var_one = 'Hello';
$var_two = 'World';
get_partial( 'templates/cards/post', compact( 'var_one', 'var_two' ) );
In template, just use $var as normal:
echo $var_one, ' ', $var_two;