Hi freefincal
Thanks for your question. It depends on your excact usecase. If you want to bulk hide the featured images of all your posts, this is the SQL command to go with:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT ID, "cybocfi_hide_featured_image", true FROM wp_posts WHERE post_type
= "post" AND ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = "cybocfi_hide_featured_image");
(assuming you use the default wp_
table prefix).
What the command does
* INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
tells the database to add a specific meta info.
* SELECT ID, "cybocfi_hide_featured_image", true FROM wp_posts
tells it to use the posts id as post_id, the plugin specific meta key cybocfi_hide_featured_image
and true
in order to actually hide the image.
* WHERE post_type = "post"
specifies, which posts should be affected. In the given example, it limits the insert of the meta info to all posts (but ignores any other post type).
* AND ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = "cybocfi_hide_featured_image")
makes the command idempotent, so it doesn’t matter, if you execute it multiple times. Additionally, it prevents changing any posts, that you’ve edited since you’ve installed and activated the plugin.
Please let me know, if you have any further questions.
Cyrill