Created
July 30, 2019 22:15
-
-
Save aaronsummers/dbf8fa456977ac763df06fe5c427d075 to your computer and use it in GitHub Desktop.
Add a metabox displaying a shortcode with the current posts ID
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
function shortcode_output() { | |
global $post; | |
// Get the data | |
$id = $post->ID; | |
// Echo out the field | |
echo '<input type="text" name="_id" value="[elab_gallery id=' . $id . ']" class="widefat" readonly />'; | |
} | |
function ve_custom_meta_boxes() { | |
add_meta_box('corporate_gallery_id', 'GALLERY SHORTCODE<br><small>This shortcode is unique to this gallery.</small>', 'shortcode_output', 'post', 'side', 'high'); | |
} | |
add_action('add_meta_boxes', 've_custom_meta_boxes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment