Passing variables to templates (alternatives to globalizing variables)

You could also use this function:

set_query_var('foo', $foo);

WP will extract and expose all query variables in every template it loads, so you will be able to access it as $foo

Leave a Comment