Skip to content

Instantly share code, notes, and snippets.

@jayseventwo
Created September 22, 2013 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayseventwo/6664782 to your computer and use it in GitHub Desktop.
Save jayseventwo/6664782 to your computer and use it in GitHub Desktop.
Add global custom content areas for your WordPress website. Add to functions.php
add_action('admin_menu', 'add_gcf_interface');
function add_gcf_interface() {
add_options_page('Opening hours', 'Opening hours', '8', 'functions', 'editglobalcustomfields');
}
function editglobalcustomfields() {
?>
<div class='wrap'>
<h2>Opening hours</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p><strong>Enter content here (HTML included)</strong><br />
<textarea name="open_hours" cols="100%" rows="7"><?php echo htmlentities(get_option('open_hours')); ?></textarea></p>
<p><input type="submit" name="Submit" value="Update Options" /></p>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="open_hours" />
</form>
</div>
<?php
}
// add below to template where required
<?php echo get_option('open_hours'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment