📜  get_template_part 参数 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:49.533000             🧑  作者: Mango

代码示例1
//NEW CLEAN way (WP 5.5.0 >=) of passing variables to template parts 

$data = array('foo'=>'bar');

//add your variables as a third parameter
get_template_part( 'template-parts/file', 'name', $data );

//In the template part itself: (IMPORTANT NOTE: the name of the variable has to be args)
echo $args['foo'];