Title: Adding PHP Variables from .php files.
Last modified: August 18, 2016

---

# Adding PHP Variables from .php files.

 *  [ghowner](https://wordpress.org/support/users/ghowner/)
 * (@ghowner)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/adding-php-variables-from-php-files/)
 * I’m currently having issues on using variables from other php files, on my wordpress
   templates.
 * Anyone know a solution that works or you’ve tried that works?
 * Thank you very much 🙂

Viewing 1 replies (of 1 total)

 *  [vince2006](https://wordpress.org/support/users/vince2006/)
 * (@vince2006)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/adding-php-variables-from-php-files/#post-556318)
 * I had a similar issue and founf the easiest way was to add an include statent
   in either the loop of in the particular template where you want the variables
   from another php file to work.
 * For instance, I have a non WP script that displays photos from another php script.
 * Let’s call the other script other.php
 * I first created a template file by copying source code from my single.php file
   in my theme.
 *     ```
       <?php
       /*
       Template Name: My_Modified_Template
       */
       ?>
       <?php include (TEMPLATEPATH . '/header.php'); ?>
       <?php include ('other.php'); ?>
       ```
   
 * Of course the location of ‘other.php’ above is relevant to the root of the domain
   and my WP install is also in the root, so you’d need to change:
 * `<?php include ('other.php'); ?>` to the location of your file so perhaps if 
   your file is in /scripts then the include statement would be:
 * `<?php include ('/scripts/other.php'); ?>`
 * Perhpas this will work, depending on the type of outside php script you are running.
 * V.

Viewing 1 replies (of 1 total)

The topic ‘Adding PHP Variables from .php files.’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vince2006](https://wordpress.org/support/users/vince2006/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/adding-php-variables-from-php-files/#post-556318)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
