lundi 2 février 2015

Passing a variable to get_template_part


The WP Codex says to do this:



// You wish to make $my_var available to the template part at `content-part.php`
set_query_var( 'my_var', $my_var );
get_template_part( 'content', 'part' );


But how do I echo $my_var inside the template part? get_query_var($my_var) does not work for me.


I've seen tons of recommendations for using locate_template instead. Is that the best way to go?





Aucun commentaire:

Enregistrer un commentaire