Title: php include problem
Last modified: August 19, 2016

---

# php include problem

 *  [miocene22](https://wordpress.org/support/users/miocene22/)
 * (@miocene22)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-problem-2/)
 * I’m in the process of modifying an install of wp e-commerce plugin.
    One of the
   customisations is the inclusion of some social media buttons.
 * I am calling them manually rather than using a plugin for a number of reasons
   and the method I am using is by using php include to call a php file containing
   the relevant code for the buttons.
 * This method work great for my theme files (e.g. single.php) but I also want to
   add it to a WPEC theme file (which is stored in wp-content/plugins/wp-e-commerce/
   themes/default). My social button code file is stored in my theme directory so
   I added this code to the WPEC theme file:
 *     ```
       <?php
       $path = bloginfo('template_directory') . '/social_buttons.php';
       include $path;
       ?>
       ```
   
 * But I receive an error:
 * > [http://localhost/serge/wp-content/themes/serge](http://localhost/serge/wp-content/themes/serge)
   > 
   > Warning: include(/social_buttons.php) [function.include]: failed to open stream:
   > No such file or directory in C:\xampplite\htdocs\serge\wp-content\plugins\wp-
   > e-commerce\themes\default\single_product.php on line 247
   > Warning: include() [function.include]: Failed opening ‘/social_buttons.php’
   > for inclusion (include_path=’.;\xampplite\php\PEAR’) in C:\xampplite\htdocs\
   > serge\wp-content\plugins\wp-e-commerce\themes\default\single_product.php on
   > line 247
 * Any ideas?
 * Edit: When I just echo $path it outputs: [http://localhost/serge/wp-content/themes/serge/social_buttons.php](http://localhost/serge/wp-content/themes/serge/social_buttons.php)
   which is correct. So why doesn’t it include properly?

Viewing 1 replies (of 1 total)

 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-problem-2/#post-1897186)
 * You should be using `TEMPLATEPATH`
 *     ```
       <?php
       $path = TEMPLATEPATH . '/social_buttons.php';
       include $path;
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘php include problem’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [Simon Prosser](https://wordpress.org/support/users/pross/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/php-include-problem-2/#post-1897186)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
