Wordpress不包括我的php文件
这是我调用php文件的代码:Wordpress不包括我的php文件,php,wordpress,Php,Wordpress,这是我调用php文件的代码: <section style="width:100%; height:120px; clear:both;" > <section class="campaign_statistics" style="background-color:#EFEFEF;"> <?php include('progress_chart.php'); ?> </section> </sectio
<section style="width:100%; height:120px; clear:both;" >
<section class="campaign_statistics" style="background-color:#EFEFEF;">
<?php include('progress_chart.php'); ?>
</section>
</section>
<?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>
'
;
?>
但是,当我调用页面时,页面上没有显示任何内容,当我查看页面源代码时,我看到的是:
<section style="width:100%; height:120px; clear:both;" >
<section class="campaign_statistics" style="background-color:#EFEFEF;">
</section>
</section>
除了我的php之外,所有东西都包括在内。所有这些在周五都运作良好。今天早上我去查看我的网站,它没有显示php文件中的内容。wordpress有问题吗?我已经检查了所有代码,没有发现任何错误,周末也没有做任何更改
以下是我的php文件的部分内容:
<section style="width:100%; height:120px; clear:both;" >
<section class="campaign_statistics" style="background-color:#EFEFEF;">
<?php include('progress_chart.php'); ?>
</section>
</section>
<?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>
'
;
?>
等等。。。大约有20个。它们是javascript调用。这些内置wordpress函数中的任何一个都应该工作,而不是简单的包含:
get_template_part ('progress_chart');
或
编辑:如果希望进度图表能够访问包含它的文件n中的变量,请使用“include locate_template()”。出于某种原因,get_template_部分不允许这样做 如果将
include()
切换到require()
,会发生什么情况?能否直接从浏览器的地址栏调用progress\u chart.php?@WhyAyala-谢谢。您在哪里定义$blog\u id
?你能在progress\u chart.php中添加var\u dump($blog\u id)
,这样我们就可以看到它的值了吗?$blog\u id似乎是一个变量<代码>_ID()
或获取_ID()你是WordPress吗functions@WhyAyala-但设置是否正确?你的第二个建议奏效了。你知道为什么我的普通电脑会停止工作吗?我仍然不知道原因是什么。很高兴它起作用了。我真的不知道你的包为什么停止工作了。一定有什么东西改变了,不知怎么的,这是我能说的最多的了。