Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Using the get_option() function to retrieve custom theme options seems to only work when placing

$options = get_option('plugin_options');

within index.php , yet all my references for using the settings api seem to place it above the doctype within header.php yet this fails.

It simple doesn't echo anything.

If placed above doctype within header.php print_r works and can access the array. It seems $options is only accessible within the template file it's defined.

share|improve this question

closed as not a real question by toscho Feb 18 at 23:59

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

global $options;
// do something with $options

PHP is only aware of the globals defined in the same file normally, you can make it aware of the others by declaring a global variable. This is why you see things like global $wpdb;

share|improve this answer

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