WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 the title will work for a file. You can use get_template_part() function to inlude your file within a wordpress template file like single.php

Function Reference/get template part

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.