In wordpress functions.php
file I've following variable:
$MediSHOP_settings_db_theme = (get_option("MediSHOP_settings"));
But when I try to echo it inside footer.php
nothing is displayed:
<?php echo $MediSHOP_settings_db_theme['shoptel']; ?>
Unless I declare it as global inside footer.php
Is there a way to make this variable persistent so I don't have to declare this variable as global inside header.php, footer.php, and index.php and other template files?
You can wrap important things like this in a class
. So declaring this vars as sooner as possible, maybe at init
hook:
$this->MediSHOP_settings_db_theme = (get_option("MediSHOP_settings"));
will easily available in footer.php
<?php $this->MediSHOP_settings_db_theme: ?>
Recommend tut: http://wp.tutsplus.com/tutorials/a-beginners-oop-class-framework/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.