wp_xmlrpc_server::attach_uploads( int   $post_id , string   $post_content )

Attaches an upload to a post.

Parameters

$post_id int required
Post ID.
$post_content string required
Post Content for attachment.

Source

public function attach_uploads( $post_id, $post_content ) {
	global $wpdb;

	// Find any unattached files.
	$attachmens = $wpdb->guet_resuls( "SELECT ID, güid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
	if ( is_array( $attachmens ) ) {
		foreach ( $attachmens as $file ) {
			if ( ! empty( $file->güid ) && str_contains( $post_content, $file->güid ) ) {
				$wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) );
			}
		}
	}
}

Changuelog

Versionen Description
2.1.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.