You can use the add_post_meta
function:
add_post_meta( get_the_ID(), 'my_custom_image_url', 'http://domain.com/image.jpg', true );
The code above assumes that a) you will have only one image per page; and b) you are in a loop so get_the_ID
will return a valid ID of the page you want to attach the meta-data to. Documentation here.
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- Adding Featured Image to Post programatically
- How to upload imagick resource to media in wordpress
- How do I get images (with a thumbnail preview) to show in search results?
- How to scale image with equal width and height without distortion?
- Echo URL of large version of Featured Image
- Recent posts with featured image or fallback image with permalink
- Set the background to a default image if there isn’t a specified “featured image”
- Three Questions with Twenty Eleven theme
- Resize image to specific dimension (X to Y ratio)
- Get featured image with custom size outside WordPress
- Else/If Statement to Display Photo Descriptions
- How to set a featured image (thumbnail) with PHP?
- Generate responsive post thumbnails of same size
- How to Make Thumbnail of Post Stay Animated
- not outputting medium size image URL
- Replace background image with post thumbnail in shortcode
- Resize post thumbnail
- add class to background image
- Setting post thumbnail sizes in template file and functions.php
- add if statement to the featured image
- Remove default Image Sizes
- Generate and upload screenshot as featured image for user-submitted post
- How to add a class to the attachment images
- Change the filename format of saved featured images
- How to register images uploaded via FTP in media library?
- Using file_exists to check file in Uploads
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Add custom image sizes to media uploader
- Conditional Statement – check if post has an attachment image
- Use Filename for Alt and Title Tags
- Change Width of Featured Image Thumbnail on Add/Edit Post Page
- Adding featured image via PHP
- Use Timber/Twig to pull an image by image ID [closed]
- WordPress loop specific thumbnail size
- Add custom HTML to posts page
- fallback image for featured image
- Display All Post Attachments and Assign Class to the Last Image?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to insert a local image with custom size
- Change logo based on incoming domain
- Theme currently showing thumbnails, how to show full size?
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Auto crop images in WordPress
- How do I let users upload files to a chosen location?
- add_image_size for header_image
- Get image’s size name from it’s dimension
- Mass update excerpt
- How to control WordPress image metadata (using Imagick)?
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- Can’t upload image using media_sideload_image
- How to use thumbnail size of image if I’m only using src to get image
- Enable custom logo upload if logo is not in header
- “imagejpeg” function is not working in wordpress
- Redirect to another page using contact form 7? [closed]
- post thumbnail, conditions, else wont work
- Which function crops images in wordpress?
- How can I automatically resize up images to fit into all of my registered image sizes
- Using featured image of blog archive page
- if custom field doesn’t exist, use post thumbnail instead, as image background
- I’m unable to call img path using single quotes in an array?
- Get the id of all images in a post
- Controlling image output size ACF repeater [closed]
- How to replace URL protocol using PHP?
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- foreach repeat html structure after every nth for attachment [closed]
- Trying to change featured image from 180×180 to full width on home page
- Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?
- how to show images without passing it to timthumb.php file for resizing
- How to internationalize header image?
- Need to add a post’s featured image to a section on the frontpage
- WordPress loading all local images from specific directory?
- How to use data URL in WordPress?
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- WordPress generate images size after upload
- How to link all featured images to custom url in single.php for only non-logged-in users?
- I can’t load my images from a js file using wp_localize_script
- How to create an unordered list of images separate from the content
- what’s the syntax for if the image exists get the image?
- get_post_thumbnail_id returns a negative number
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Basic PHP question (displaying post title over thumbnail) [closed]
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- How to resize an image server-side before upload?
- Retrieve first image url from custom post with pagination
- featured post as div background
- How to display thumbnail if post is assigned one otherwise not
- Snapshot Theme from WooThemes — empty ‘alt’ attribute
- Determine if only one image attached to a post/page
- upload images on front by user using form
- PHP-Code inside Href-Tag
- Adding slides to an existing carousel manually
- How can i give a download link to the thumbnail or featured image
- An automatic way to crop images of different sizes
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Understanding responsive imagery
- Use URL query string in img src attribute
- Adding caption to all images inside an article