dougou8639 2013-08-26 16:57
浏览 11
已采纳

Wordpress不包括我的php文件

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.

  • 写回答

1条回答 默认 最新

  • douyan9417 2013-08-26 18:29
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂