I am publishing to Wordpress via PHP, as follows.
- Create post with wp_insert_post()
- Add Featured Image with wp_insert_attachment()
Problem:
When creating the Post, there is a Plugin (SNAP autoposter) that will automatically publish it on Facebook. But, as obvious, it does not wait until the featured image is attached.
Question:
How should I proceed to publish the post with an already assigned attachment?
Thanks a lot for your help :)
Don't publish the post until the attachment has been added.
post_status
todraft
when you callwp_insert_post
.wp_publish_post
to publish the post.If the plugin is setup correctly, it will be listening for the status transition to publish.