How to attach 1000's of unattached images

admin2025-06-03  2

I imported a few hundred products with Shopmaster. All the images that were imported with the products are unattached. I want to use Media File Renamer to rename the images to the post title but it doesn't work because the images aren't attached for some reason. I have spent all day trying to figure this out but I'm at a loss. Any ideas? thanks

i have found that this code in SQL attaches the featured image of all the posts, but not the rest. any ideas to update it would be great.

 UPDATE wp_posts AS p
INNER JOIN (
  SELECT p.ID AS attachment_id, pm.post_id AS post_id
  FROM wp_posts p
  JOIN wp_postmeta pm
  ON pm.meta_value = p.ID
  WHERE (
    pm.meta_key = '_thumbnail_id'
    AND
    p.post_type = 'attachment'
    AND
    p.post_parent = 0
  )
) AS b ON p.ID = b.attachment_id
SET p.post_parent = b.post_id
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748953191a315112.html

最新回复(0)