我最近更新了我的WordPress站点和我所有的插件和主题到当前版本。在更新之后,我的get侧栏()出现了问题;
我的sidebar.php有以下代码:
<?php if ($cfs->get('sidebar_recent-event_text') || $cfs->get('sidebar_recent-event_number')) { ?>
<div class="recent-event-call pie-rounded">
<p><?php echo $cfs->get('sidebar_recent-event_text'); ?></p>
<p class="phone-number"><?php echo $cfs->get('sidebar_recent-event_number'); ?></p>
</div>
<?php } ?>
<?php if ($cfs->get('sidebar_covered_text')) { ?>
<div class="what-is-covered pie-rounded">
<h4><?php echo $cfs->get('sidebar_covered_header'); ?></h4>
<?php echo $cfs->get('sidebar_covered_text'); ?>
</div>
<?php } ?>
<?php if ($cfs->get('sidebar_covered_text_mobile')) { ?>
<div class="what-is-covered what-is-covered-mobile pie-rounded">
<h4><?php echo $cfs->get('sidebar_covered_header_mobile'); ?></h4>
<?php echo $cfs->get('sidebar_covered_text_mobile'); ?>
</div>
<?php } ?>
<?php if ($cfs->get('sidebar_questions_text')) { ?>
<div class="questions pie-rounded">
<button class="questions-link-button" onclick="location.href='mailto:<?php echo $cfs->get('sidebar_questions_link'); ?>'"></button>
<h4><?php echo $cfs->get('sidebar_questions_header'); ?></h4>
<?php echo $cfs->get('sidebar_questions_text'); ?>
</div>
<?php } ?>在我的模板文件中
<?php get_sidebar(); ?>我得到并错误上写着:注意:未定义变量: sidebar.php中的cfs在第1行
如果我用一些简单的html删除php文件中的代码,如
<div><b>test test test test</b></div>然后它就装得很好。
如果我从sidebar.php文件中复制php代码并将其直接粘贴到模板文件中,那么它也可以很好地加载。因此,由于某种原因,sidebar.php中的php没有运行。不知道如何排除故障。
我不是一个PHP,所以我不知道为什么PHP没有加载。你能帮帮我吗。
发布于 2018-05-15 19:19:53
如果这是在引用自定义字段套件插件,那么将其设置为global在sidebar.php顶部会有帮助吗?
<?php global $cfs; ?>
这将允许您访问
发布于 2018-05-15 19:15:32
您的侧边栏没有加载,因为它指定了错误:
Notice: Undefined variable: cfs in sidebar.php on line 1您可以通过在.htaccess文件中添加以下行来获得有关错误的更多信息:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_value error_log /home/path/public_html/domain/PHP_errors.log$cfs可以是任何东西--但是我以前在自定义字段套件插件中看到过这个变量。如果这个插件没有安装和激活,你可能想试一下,看看你的侧边栏是否正常工作。
https://stackoverflow.com/questions/50357480
复制相似问题