将变量传递给自定义模板范围

<?php 
set_query_var( 'passed_var', $my_var ); 
get_template_part( 'foo', 'bar' );
?>

在 foo-bar.php 访问它

<?php echo $passed_var; ?>