Title: PHP include containing a posts title.
Last modified: August 18, 2016

---

# PHP include containing a posts title.

 *  Resolved [joshuatw](https://wordpress.org/support/users/joshuatw/)
 * (@joshuatw)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/)
 * I want to add a php include to my template. I want it to include a file called
   the title of the post. I’ve tried several thing, but I quite honestly don’t have
   any programming abulity. The most progress I made is using the following code:
 * ‘<?php
    $startinclude = “<?php include(‘[http://www.joshuatwood.com/includes/&#8221](http://www.joshuatwood.com/includes/&#8221);;
   $endinclude = “.php’); ?>”; echo $startinclude; $thumbs = the_title(); echo $
   endinclude; ?>’
 * This returns to proper code for an include, but is not parsed by the server. 
   Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-452983)
 * You’re not using include properly, what that code will do is write the contents
   to the page sent to the browser. You want to do this:
 * `<?php
    include('http://www.joshuatwood.com/includes/' .the_title(). '.php');?
   >
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-452984)
 * I am not a coder by any means but… you should never use a URI in an include, 
   only path.
 *  Thread Starter [joshuatw](https://wordpress.org/support/users/joshuatw/)
 * (@joshuatw)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-452991)
 * That didn’t work either. I’m getting an error message saying that “.php” doesn’t
   exist, with the name of the post preceding the warning message.
 * Just out of curiosity, why is it bad to use the URI in an include?
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-452996)
 * As I said, not being a coder I just rely on what the coder gurus are saying here
   in the forum.
    And having spent a lot of time around here, I saw many times this
   warning from coders that I trust.
 *  Thread Starter [joshuatw](https://wordpress.org/support/users/joshuatw/)
 * (@joshuatw)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-453042)
 * I got it figured out… I was staring at the code and realized that the “the_title()”
   function was calling another function and tried it… This is how I got it to work…
 * include(‘../includes/’ .get_the_title(FALSE). ‘.php’);
 *  [RECEP KARACA](https://wordpress.org/support/users/rcpkrc/)
 * (@rcpkrc)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-453251)
 * look strange. l am also looking something like that.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP include containing a posts title.’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 6 replies
 * 4 participants
 * Last reply from: [RECEP KARACA](https://wordpress.org/support/users/rcpkrc/)
 * Last activity: [18 years, 10 months ago](https://wordpress.org/support/topic/php-include-containing-a-posts-title/#post-453251)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
