This morning I needed to pass a variable to a file that I was including using the WordPress get_template_part function. I was fiddling around with global variables when I thought there must be a better way. There is. Locate and includeYou can use the WordPress locate_template function within PHP’s include(). It’s done like this: [code]include(locate_template(‘your-template-name.php’));[/code] All
![Passing variables to get_template_part() in WordPress - Keith Devon](https://cdn-ak-scissors.b.st-hatena.com/image/square/094bfcbcf2bb097decde59e5b9c98401e9c6beb4/height=288;version=1;width=512/https%3A%2F%2Fkeithdevon.com%2Fassets%2FIMG_27731-1024x547.jpg)