0

I am using word press theme option panel and using those in my header.php without any issues, code as follows...

<?php
    // loading theme options.  used in header.php
    global $options;
    foreach ($options as $value) {
        if (get_settings( $value['id'] ) === FALSE) { 
            $$value['id'] = $value['std']; 
        } else { 
            $$value['id'] = get_settings( $value['id'] ); 
        }
    }
?>

<?php echo $aagt_fb_url; ?> //loads fb url

But if i use <?php echo $aagt_fb_url; ?> in index.php it doesn't work, can you please help me to resolve this issue. thanks.

0

If you are using some custom global theme options, I’d set them in functions.php. Then you access them from any template if you declare them global first.

// functions.php
<?php
$aagt_fb_url = 'foo';

-

// template file like header.php, index.php, etc.
<?php
global $aagt_fb_url;
echo $aagt_fb_url;
3
  • thanks, if i paste options functions to retrieve values in functions.php, it doesn't work after using global $aagt_fb_url; echo $aagt_fb_url; – seoppc Jun 13 '12 at 9:39
  • using <?php include('options.php'); ?> at every template file solves my problem. – seoppc Jun 13 '12 at 9:58
  • Okay, to avoid having to include that file in every template maybe you could make $GLOBALS work for you? – Geert Jun 13 '12 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.