All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
3k views

Passing variables to template parts

I have one template file videos.php which has the following line of code in it (aswell as a load of HTML): <?php get_template_part('loop', 'feed-videos' ); ?> inside that template part, I have ...
0
votes
3answers
671 views

If I define a variable in header.php, how do I make it available to templates?

I've defined a variable in my child theme header.php. I'd like to get the value of this variable from one of the templates that is rendered after the request in which the header.php is called. So, ...
1
vote
3answers
174 views

Accessing $post variable from template part

Here is a section of code that I have in a template file — to display sub-navigation if the page has child-pages: <?php // display sub-nav if page has children ?> <?php $children = get_pages(...
54
votes
9answers
62k views

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 ...