views:

15

answers:

0

Hi. I'm working on a piece of code that display a custom field from Wordpress inside a function. I need to have the variables for the custom field outside the function, then I'm using PHP's 'global' to call the variable into the function, but it isn't working. Here's the code; whats wrong with it?

<?php
$meta = get_post_meta($post->ID, 'slideshow', true);

function slideshow_meta_box() {
  global $meta;
  echo $meta;
} ?>

It just isn't working. It works when I put the first line into the function, but that isn't feasible because I need to be able to access $meta with another function.