I am creating a simple "global settings" plugin, which simply saves a few text fields. Saving works as intended, and I can retrieve my data in frontend as follows:
<?php $options = get_option('wpglobalsettings'); ?>
<?php echo $options['wpglobalsettings_image1']; ?>
What I would like though, would be to avoid having to call get_option('wpglobalsettings'); on each page I plan to use my plugin on.
So I was thinking I could add my $options to an action hook. I did the following, but it doesn't work ( I get an empty array.
function wp_global_settings_frontend(){
$options = get_option( 'wpglobalsettings' );
}
add_action('the_content', 'wp_global_settings_frontend');
Can You help? Many thanks!