在wordpress functions.php
文件中,我有以下变量:
$MediSHOP_settings_db_theme = (get_option("MediSHOP_settings"));
但是当我尝试在里面回显它时footer.php
什么也没有显示:
<?php echo $MediSHOP_settings_db_theme['shoptel']; ?>
除非我将其声明为全局内部页脚.php
有没有办法使这个变量持久化,这样我就不必在标题.php、页脚.php和索引和其他模板文件中将此变量声明为全局.php?
您可以将这样重要的事情包装在class
中。所以尽快声明这个变量,也许init
钩子:
$this->MediSHOP_settings_db_theme = (get_option("MediSHOP_settings"));
在页脚中很容易找到.php
<?php $this->MediSHOP_settings_db_theme: ?>
推荐嘟嘟:http://wp.tutsplus.com/tutorials/a-beginners-oop-class-framework/