0

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
  • 1
    Imported from where? How do you know which post an image should be attached to? – Milo Feb 1 at 17:05
  • yea thats a good question, im not sure how the post knows to display the images for each product. I was guessing there was an image link in the code it pointed to.. I imported them through the website "shopmaster.com" it's an aliexpress imported – Nicholas Taylor Feb 2 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.