Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add form
- function wpse261260_add_checkbox_thumbnail ($content) {
- global $post;
- $text = __( 'Link to full image', 'your-textdomain' );
- $id = 'link_to_featured_image';
- $value = esc_attr (get_post_meta ($post->ID, $id, true) );
- $label = '<label for="' . $id . '"><input name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $value . ' "'. checked( $value, 1, false) .'> ' . $text .'</label>';
- return $content .= $label;
- }
- add_filter ('admin_post_thumbnail_html', 'wpse261260_add_checkbox_thumbnail');
- // Save form
- function wpse261260_save_checkbox_thumbnail ($post_id, $post, $update) {
- $value = 0;
- if (isset ($_REQUEST['link_to_featured_image'])) {
- $value = 1;
- }
- update_post_meta ($post_id, 'link_to_featured_image', $value);
- }
- add_action ('save_post', 'wpse261260_save_checkbox_thumbnail', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement