Skip to content

Instantly share code, notes, and snippets.

@raamdev
Forked from devinsays/gist:4711952
Created October 22, 2013 22:06
Show Gist options
  • Select an option

  • Save raamdev/7109032 to your computer and use it in GitHub Desktop.

Select an option

Save raamdev/7109032 to your computer and use it in GitHub Desktop.

Revisions

  1. @devinsays devinsays created this gist Feb 5, 2013.
    21 changes: 21 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?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;
    }
    ?>