Make custom field values in all posts page in admin panel clickable to retrive them later

(Istiaque Ahmed) #1

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. While toggling it I need to make it bold or the reverse as well.

How can I do that ?

How can I do that ?

(Piet) #2

Can you please clarify the question? In the first part you’re talking about admin columns (backend of the site) and in the second part you switch to frontend. Why would you want to show the featured image on the frontend with a conditional related to the admin column?

Why not simply use

if ( has_post_thumbnail() ) {

(Leland Fiegel) #3

Also unclear, but in any case, there’s no reason to use a “YesOrNo” value.

You can get the same effect by using a conditional to check for the existence of a featured image.

Do you just have one featured image per post? If so, use the conditional that @pietbos mentioned above. You want to avoid reinventing the wheel, as core already provides this functionality.

If you have multiple featured images, there are plugins like Multiple Featured Images that can help.