將變數傳遞給自定義模板範圍

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

在 foo-bar.php 訪問它

<?php echo $passed_var; ?>