post – import alt text in set_post_thumbnail

you have a global alt (meta) The value associated with an attachment (viewable when managed via “media” in admin) that is stored in the post meta table, but on a post by post basis, when you access that piece of media The optional value you set is stored more literally as a part of the post content HTML.

I think the issue is that wordpress doesn’t respect the global (main) attachment alt value and will update the attachment meta when you put it in the post and set the alt text, whereas for the specific post alt text (post content html) For that the attachment will be the same as the one you set at the time of inserting it.

by calling update_post_meta Feather _wp_attachment_image_alt You are only likely to get a short term fix to set what the current alt value is, it will change the next time you put it in and set a different alt value.

Leave a Comment