Created
September 22, 2013 23:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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