get_option function

You are using get_option() wrong, first variant, so take another look at the get_option() documentation. Basically you can’t directly access an array element with the function, it just doesn’t support it.

The second variant should be possible, but you need at least PHP 5.4 – if I’m not totally mistaken; I don’t know anything about dreamweaver.

The reason why you can’t access the variable everywhere you want is the variable scope, read up on it at the PHP Manual: Variable scope.

The easiest thing I imagine is to do it the old fashion way, just make a function you can use. Exemplary like this:

function wpse_179693_echo_my_options_array_value() {
    $social_options = get_option( 'sultenhest_theme_social_options' );
    if ( isset( $social_options['twitter'] ) ) {
        echo $social_options['twitter'];
    } else {
        return FALSE;
    }
}

Leave a Comment