Site icon Hip-Hop Website Design and Development

set and unset the custom field value

While showing all the posts together in admin panel, I have a custom column ‘Featured Image’. And this column has a value YesOrNO.

To set the column name : I have inside functions.php:

function set_column_heading($defaults) {
    $defaults['featured_image'] = 'Featured Image';
    return $defaults;
}
add_filter('manage_posts_columns', 'set_column_heading');

In order to set the column value, I have :

 function set_column_value($column_name, $post_ID) {
        if ($column_name == 'featured_image') {
            $post_featured_image = get_featured_image($post_ID);
            if ($post_featured_image) {
                echo 'YesOrNO';
            }
        }
    }

    function get_featured_image($post_ID) {
        $post_thumbnail_id = get_post_thumbnail_id($post_ID);
        if ($post_thumbnail_id) {
            $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
            return $post_thumbnail_img[0];
        }
    }
add_action('manage_posts_custom_column', 'set_column_value', 10, 2);

Yes , I get the column name and value (i.e. YesOrNo) as I expected. In wordpress frontend, I want to show the featured images of posts with a condition. The condition is : I need a click handler on the column value (i.e. YesOrNo) so that I can toggle it as chosen or unchosen and I like to show featured images from the chosen ones only.

How can I do that ?