Answers:
Is post_guid the image location
reference? Or is the path to the image
stored somewhere else?
$post->guid is the record in a post which holds the URL for your attachment.
Where is featured image set?
featured image is saved as post meta so use update_post_meta()
once you have the attachment id:
update_post_meta( $post->ID, '_thumbnail_id', $attachment_id );
Is this the best way of doing this?
Its a lot of work for several thousand posts and any way you choose will cause you some “pain” but it seems like a reasonable way of accomplishing this.
Related Posts:
- Programmatically get images by URL and save in uploads folder
- How to find attachment by it’s name?
- Insert an image into a post by API
- Show prev and next post links for parent post of current image in attachment page?
- How do you import images from a URL in your post?
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Can we use featured image as third party website image URL
- Custom image size not displaying with wp_get_attachment_image()
- How to echo images Urls from a wordpress post, that are relally in the post
- attachment_fields_to_save first parameter is null
- Troubles with code for upload a image
- How can I use an image from an external source without uploading it to the media library
- Programmatically adding images to media library
- Can I attach image to post without adding it to post?
- How to automatically add rounded corners to thumbnails?
- How to change image type for specific size?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Remove title attribute from images
- How to limit number of images being printer out in “Set Featured Image” pop up?
- Get attachment ID of author_meta image – Attachment Metadata
- Black and White thumbnails
- How to grab first image attached to post and display in RSS feed?
- Double thumbnails?
- Separate attachment images from post loop
- copy attachment title to description and alt text
- No srcset for hard-cropped thumbnails
- Allowing post attachments without allowing to insert in text
- Rename attachments during upload
- Regex to turn embedded images in to attachments
- Removing Title Tag from Thumbnails
- Regenerate missing _wp_attachment_metadata
- Make alt text required when setting a featured image
- Get original image from thumbnail URL
- Display one random image, but only if landscape
- Is there a way to get attachment data?
- How to change image url?
- attach unattached featured images to respective posts
- WordPress reduces the full size image and uses it as the original
- Remove image classes from post thumbnail output
- get the image of the post
- media_sideload_image with rewritten urls?
- Special purpose photos with each post
- SVG Featured image not shown in twitter
- Set Post Image Using Shortcode
- Print specific image size in galley loop
- WordPress crops images differently on retina screens?
- Exclude featured image from attachment loop
- Out of memory error reporting
- How can I attach hotlinked images in posts/pages within the same server?
- Multiple images in one attachment page
- WordPress Image Attachment using remote image
- Exclude images from “inserted into post” when trying to get attachments
- Set size for attachments
- How can I add a “data-pin-nopin” the featured image html?
- Auto delete attachments that are older than x days
- Images stopped loadding after adding SSl
- Images attached to posts from library link to 404 error page
- Help to upload post attachments from Ajax
- Setup Featured image on all posts from thesis thesis_post_image custom field?
- Generate images to be associated for tag and category?
- Should I not compress my jpeg files before uploading to avoid double compression?
- Is it possible to preserve original images in order to change image size later?
- Generating a certain sized thumbnail on the fly?
- Get images attached to a specific page
- add_image_size function not working
- Why doesn’t WordPress use the smaller sized image?
- What sense makes medium_large_size_h => 0?
- How do I link a featured photo to it’s post?
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Use default image as var
- How to test if there are no more previous or next image on attachment page?
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- What is the plugin to import image from URL?
- Excluding post thumbnail from the attachment.php when using wordpress gallery
- How do I display the featured image from an image gallery using a reference in code? (example within)
- How to replace post image url before posting using api?
- Using different size thumbnails on different parts of my site… with functions.php?
- attach several images to post + gallery
- SQL: How to find all attachments that are not used in any posts/pages/custom_post_types
- Force WordPress to always generate a thumbnail for original image
- Get post thumbnail in specific size
- Allow users to upload attachments to certain posts
- featured image in custom poste type (backend)
- stop wordpress from resizing feature gif images
- Get “Image CSS Class” value from the Advanced Options section
- Uploaded images not showing properly using wordpress
- Theme page headers and rotator images not assigned after website migration
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- Declare global variable that can be used on other function
- attachment.php & flexslider—linking thumbnail to specific image
- Create a custom attachment thumbnail for quick page load
- How can I hide previous_image_link() on first attachment page?
- Black and White Thumbnail in WordPress Gallery
- Upload unnattached image from frontend
- Image attachement management – a philosophical question
- wp_get_attachment_link() add rel attribute if the link points to direct image
- Stop Attachment image names from taking top level permalink
- Getting top Image From the Gallery and printing out a thumbnail with Exact Dimensions
- How to import external media items into wordpress media library (without using storage)
- Remove one srcset entry from wp_get_attachment_image