WordPress.org

Ready to get started?Download WordPress

Forums

Adding PHP Variables from .php files. (2 posts)

  1. ghowner
    Member
    Posted 7 years ago #

    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 :)

  2. Vince2006
    Member
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic