Skip to content

Instantly share code, notes, and snippets.

@raamdev
Forked from devinsays/gist:4711952
Created October 22, 2013 22:06
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 raamdev/7109032 to your computer and use it in GitHub Desktop.
Save raamdev/7109032 to your computer and use it in GitHub Desktop.
<?php
/* Add a checkbox to the featured image metabox */
add_filter( 'admin_post_thumbnail_html', 'theme_featured_image_meta');
function theme_featured_image_meta( $content ) {
global $post;
// Text for checkbox
$text = __( "Don't display image on post.", 'textdomain' );
// Meta value ID
$id = 'hide_featured_image';
$value = esc_attr( get_post_meta( $post->ID, $id, true ) );
// Output the checkbox HTML
$label = '<label for="' . $id . '" class="selectit"><input name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $value . ' "'. checked( $value, 1, false) .'> ' . $text .'</label>';
return $content .= $label;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment