Import-External-Images-2 icon indicating copy to clipboard operation
Import-External-Images-2 copied to clipboard

wp_insert_post()

Open ws420 opened this issue 6 years ago • 1 comments

I add posts to wordpress using an external PHP script, something like this:

$new_post = array(
	'post_title' => $title,
	'post_content' => "blah blah <img src='https://example.com/image.jpg'> ";
	'post_status' => 'publish',
	'post_author' => $wp_user_id,
	'post_type' => 'post',
	'post_category' => array(),
	'tags_input' => array()
);
	$post_id = wp_insert_post($new_post, true);

But the images are not imported in the local library. The remote image is displayed in the post.

Is there a way I can use your plugin to import external images when posting from an external PHP script instead of using the WP admin dashboard to create a new post ?

Thanks

ws420 avatar May 08 '19 07:05 ws420

To be honest, the plugin needs a complete rewrite which will arrive much later in the year.

To do as you ask you would need to enter the dashboard and visit the plugin's settings page after your posts have been added to the site then run the image importer.

VR51 avatar May 11 '19 19:05 VR51