WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file.

I have a few variables I set inside my functions.php file for example...

$feedburnerUsername = 'username';

Now in my sidebar.php file If I try to access this variable, it is not available, how can I make it available?

share|improve this question
up vote 3 down vote accepted

Whilsts @Shaon's answer is perfectly valid, I'm of the opinion you really shouldn't be throwing configuration settings around as global variables - use a constant instead.

/* Constants are in the global scope, but can only be defined once. */
define( 'FEEDBURNER_USERNAME', 'my_username' );
define( 'FEEDBURNER_PASSWORD', 'my_password' );

If the variable needs to be dynamic (for example, if it's an option in the database), use a function that returns it:

function get_feedburner_config( $option = null )
    $config = get_option( 'feedburner' );
    $config = wp_parse_args( $config, array(
        'username' => 'default',
        'password' => 'default'

    if ( $option )
        return isset( $config[ $option ] ) ? $config[ $option ] : '';

    return $config;
share|improve this answer


global $feedburnerUsername; 

at the top of functions.php

and when you will start using it to another scope, like another file or function, write

global $feedburnerUsername; 

again before use

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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