• Resolved emtv

    (@emtv)


    Hi,

    Thanks for this great plugin. I’ve seen in FAQ how to hide featured images from displaying in posts for all NEW posts, but I’d like to run a SQL query via phpmyadmin in order to insert the meta_value ‘yes’ for meta_key ‘cybocfi_hide_featured_image’ in wp_postmeta table for all previously published posts.

    If anyone can help, I’d be really thankful !!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author cyrillbolliger

    (@cyrillbolliger)

    Hi emtv,

    Thanks for reaching out. Assuming you use the default wp_ table prefix, this should do the job:

    INSERT INTO wp_postmeta (post_id, meta_value, meta_key)
        SELECT 
            ID AS post_id, 
            'yes' AS meta_value, 
            'cybocfi_hide_featured_image' AS meta_key 
        FROM wp_posts 
        WHERE 
            post_type = 'post'
            AND 0 = (
                SELECT 
                    COUNT(*) 
                FROM wp_postmeta 
                WHERE 
                    wp_postmeta.post_id = wp_posts.id 
                    AND meta_key = 'cybocfi_hide_featured_image'
            );

    It will mark the featured image on any post as hidden, unless the post was edited after the plugin was installed and the featured image was not marked as hidden.

    Have an excellent day,
    Cyrill

    Thread Starter emtv

    (@emtv)

    Hello Cyrill, and thanks a lot for your quick and efficient reply.

    Exactly what I needed ! Have a great day too.

    eM

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘run sql query to bulk edit postmeta and hide all featured images’ is closed to new replies.