Linked Questions

2
votes
0answers
786 views

How to set featured image in wp_insert_post [duplicate]

I have a register form with upload field and when the user registers i create a new post. I need to have the uploaded picture on the featured image of the post. I have see something like this but i ...
10
votes
5answers
8k views

Get $image_id after uploading with media_sideload_image()

I want to upload an image and set it as a featured image in a post. What i tried was this: $image_id = media_sideload_image($image_url, $post_id, $post_id); update_post_meta($post_id, '_thumbnail_id',...
2
votes
1answer
2k views

why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?

I am using a new blog on WPMS (3.0.1, updating is not an option) to aggregate posts (and their featured image) from a few blogs on the same install, and I have to do it programmatically rather than ...
0
votes
2answers
3k views

Get an image from url in front end submission form

I am building a user generated content sharing theme so how can i allow visitors to upload an image from a url i mean to say that they enter the url and the image gets automatically attached this is ...
0
votes
1answer
1k views

How to save woocommerce product?

I need to import products from third-party API to woocommerce. How to save data using wp_insert_post()? name = string sku = string type = string regular_price = double description = string weight = ...
0
votes
2answers
710 views

insert thumbnail image from php script

I'm trying to insert a post image thumbnail from my php scritp. It's inserting the post, the content, a download link, and I only need to set the thumbnail image to finish my script. This is my code ...
1
vote
1answer
262 views

Featured Image uploaded, attached and set but only appearing in the media library

I am using the function in this answer to upload, attach and then [set_the_post_tumbnail][2]/featured image to a post which I am creating from an RSS feed. I ran a test and the output is showing ...
0
votes
1answer
264 views

How to get the postID inside 'content_save_pre'? Other hook?

I need to get the current PostID. I think in the function the postID is not existing yet. (Because save pre ...) add_filter('content_save_pre', 'getImageUrlOutOfContent', 10, 1); Am I right? How I ...
0
votes
1answer
82 views

Where to insert the other site image url for our wordpress post

I am scrapping contents from my others sites into my wordpress site, i did all and below is my insert query $my_post = array( 'post_title' => $my_title, 'post_status' => 'publish', ...
0
votes
1answer
78 views

How to write custom code on WordPress?

I need to write some function so that WordPress can get uploaded image from remote client tool, and found this one seems to fit my need: How do I set a featured image (thumbnail) by image URL when ...