Viewing 5 replies - 1 through 5 (of 5 total)
  • well, that’s because it’s outside the loop.

    in your page template, do something like….

    <?php
      global $current_language;
      $current_language = get_post_meta($post->ID, 'language', true);
      echo $current_language;
    ?>

    then in the footer:

    <?php
      global $current_language;
      echo $current_langauge;
    ?>
    Thread Starter zhaval

    (@zhaval)

    Thank you, Ivovic, you solved it. I did try something similar before, but did not use the

    <?php global $current_language; ?>

    in the footer again — I wonder why this is necessary, seems kind of redundant.

    Have a great day!

    variable scope in php is a little different to what you might be accustomed to.

    think of the global declaration as “pulling” the global variable into the current scope, so it needs to be done each time you want to access a global var in a different scope.

    Thread Starter zhaval

    (@zhaval)

    Thanks! Hvala?!

    Molim 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom fields not accessible in footer.php’ is closed to new replies.