Created
August 15, 2016 10:55
-
-
Save mzo84/fe78de95e0fa9c7c5c25fc394e6621c4 to your computer and use it in GitHub Desktop.
Add a global custom field
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 this to your functions.php: | |
<?php add_action('admin_menu', 'add_gcf_interface'); | |
function add_gcf_interface() { | |
add_options_page('Global Custom Fields', 'Global Custom Fields', '8', 'functions', | |
'editglobalcustom elds'); | |
} | |
function editglobalcustom elds() { ?> | |
<div class="wrap"> | |
<h2>Global Custom Fields</h2> | |
<form method="post" action="options.php"> | |
<?php wp_nonce_ eld('update-options') ?> | |
<p><strong>Amazon ID:</strong><br /> | |
<input type="text" name="amazonid" size="45" | |
value="<?php echo get_option('amazonid'); ?>" /> | |
</p> | |
<p><input type="submit" name="Submit" value="Update Options" /></p> | |
<input type="hidden" name="action" value="update" /> | |
</div> </form> <input type="hidden" name="page_options" value="amazonid" /> | |
<?php } ?> | |
// You can now display this value anywhere in your theme with the get_option() template tag: | |
<?php echo get_option('amazonid'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment