Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm including a php file in single.php, in the loop.

Is it possible to use WP variables such as the_title(), the_date(), etc in the included php file?

share|improve this question
This is a simple yes/no question that isn't well-suited to WPSE. Could you clarify your question, to describe the problem - if any - that you are experiencing while trying to include a template part file inside of single.php? –  Chip Bennett Sep 28 '11 at 13:04

2 Answers 2

up vote 1 down vote accepted

Get the title into a variable, and use the variable in the included PHP instead:

$title = get_the_title();
include "yourfile.php";


echo $title;
share|improve this answer

Yes, WordPress functions and template tags should work just fine in a template-part file included inside of a WordPress template file, such as single.php. To verify: copy/paste the code from the included file directly into single.php, and verify that the code works as intended.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.