0

I am creating a WordPress options panel based on http://en.bainternet.info/2012/my-options-panel

In the article it states to call the stored options to use

//get the data to an array
$data = get_option('demo_options');
//access each field by its id
echo $data['text_field_id'];

Which works, the only problem I have is that if I want to call some information for say the header.php and the footer.php or any other page I have to include the line

$data = get_option('demo_options');

at the top of every page otherwise I can not call the data, which seems repetitive.

I have tried to create a global variable in the functions.php file like;

global $data
$data = get_option('demo_options');

but that doesn't work.

Does anyone know how I can resolve this so I don't need to add the line to the top of every page?

Thanks

4

1 に答える 1