0

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.

4

1 回答 1

2

这些内置的 wordpress 函数中的任何一个都应该工作,而不是简单的包括:

get_template_part ('progress_chart');

或者

include locate_template('progress_chart.php');

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

编辑:如果您希望progress_chart 能够访问包含它的文件n 中的变量,请使用“include locate_template()”。由于某种原因 get_template_part 不允许这样做。

于 2013-08-26T18:29:14.930 回答