Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
Created July 30, 2019 22:15
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 aaronsummers/dbf8fa456977ac763df06fe5c427d075 to your computer and use it in GitHub Desktop.
Save aaronsummers/dbf8fa456977ac763df06fe5c427d075 to your computer and use it in GitHub Desktop.
Add a metabox displaying a shortcode with the current posts ID
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