I have a simple code where I am attaching existing in the library image to a post:
function attachToPost($attachmentId, $postId){
return wp_update_post(array(
'ID' => (int)$attachmentId,
'post_parent' => (int)$postId
));
}
The problem is that I can't attach it to a second post. I read in the internet that this is the way that WordPress works, but is there some kind of solution ?
I don't prefer plugins.