WhyAyala
WhyAyala

Reputation: 675

Wordpress not including my php file

This is my code that I have calling my php file:

<section style="width:100%;  height:120px;  clear:both;" >
    <section class="campaign_statistics" style="background-color:#EFEFEF;">

        <?php include('progress_chart.php'); ?>

    </section>
</section>

However, nothing displays on the page when I call it, and when I view the page source this is what I see:

<section style="width:100%;  height:120px;  clear:both;" >
    <section class="campaign_statistics" style="background-color:#EFEFEF;">



    </section>
</section>

Everything but my php include. All of this was working fine on friday. I go and check my site this morning and it's not displaying what's in that php file. Is there a problem with wordpress? I've gone over all my code and can't find any errors and no changes were made over the weekend.

Here is a portion of the contents of my php file:

<?php 

if ($blog_id == 1)
    echo
    '
    <script>
    var percent = String(totalProgress.getPercent());
    document.write(totalProgress.toString());
    </script>
    '
    ;

if ($blog_id == 68)
    echo
    '
    <script>
    var percent = String(alumniProgress.getPercent());
    document.write(alumniProgress.toString());
    </script>
    '
    ;
?>

etc... there's about 20 of these. They're javascript calls.

Upvotes: 0

Views: 154

Answers (1)

patricksayshi
patricksayshi

Reputation: 1395

Either of these built-in wordpress functions should work instead of a plain include:

get_template_part ('progress_chart');

or

include locate_template('progress_chart.php');

http://codex.wordpress.org/Function_Reference/get_template_part http://codex.wordpress.org/Function_Reference/locate_template

EDIT: Use "include locate_template()" if you want progress_chart to be able to access variables from the file n which it's being included. For some reason get_template_part doesn't allow that.

Upvotes: 2

Related Questions