$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'DEVILON 500MG' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/devilon500mg№10tabletok.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'URSOFLOR 200mg' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/ursoflor.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'VITAMIN C No. 20 (effervescent tablets)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/vit-c.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'VITAZIM No. 30 (tablets)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/Vitazim-brow-kz-cdr-17.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'SPECTRUM № 30' ) );

$url = '';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'demiflex' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/DemiFlex-.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Ziban 1000 mg' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Ziban-flyer.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'VITASON № 30 (tablets)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/vitason.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'ANTROLIN RECTAL CREAM 30G' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Antrolin-1.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Aksetin' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/400x400_54600.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'FLAMAX 2ML №10 (AMPOULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/flamaks-1.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'EVADOL № 60 (capsules)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/product_201904080849050.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'MEDOKLAV 312,5 MG/ ml' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/Medoclav-roll-up.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'TRICORTIN®' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/trikortin.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'REAFEM 200MG №30 (CAPSULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Reafem.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Demicalcin' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/demicalsin-box-sayt.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'liposom forte' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/брошюра-липосом.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'REAFEM 100MG №30 (CAPSULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Reafem-100.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'MEDOCLAV 156,25 MG/ML' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/medoclav-156.25.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Itami' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/rollup-itami.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Hyalofemme' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/gialofem.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'GIALGAN 20mg / 2ml No. 1 (syringe)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/806434954.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'AMELOTEX 15mg tab № 20 (tablets)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/ameloteks-tab-15mg-n20.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'IMUTERRA №30 (tablets)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Имутерра-12.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'MEDOCLAV 625MG' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/tmp_add_image_511.jpeg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Aponil №30 (TABLETS)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/aponil.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Energy' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/energy-box-sayt.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'L-ELIXIR 30 ML (DROPS)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/02/L-elixir_003.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'ALFINOR' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/400x400_50819.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'BIOZYM No. 30 (capsules)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/03/Biozyme-20-kapsul.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'ALMIRAL №5 (ampoules)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/Алмирал.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Ferractin' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/04/Ferractin-kz.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'IDRINOL 100MG №10 (AMPOULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/8817755553822.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'MEDOCLAV 1000 MG' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/tmp_add_image_652.jpeg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'AMELOTEX 5MG AMP № 5(AMPOULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/ead9eeceaeb6d2beaeacd312970c764f.jpg';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'Chondrocol No. 60 (CAPSULES)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/CHONDROCOL-KZ-NEW.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'K-ELIXIR 30 ML (DROPS)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/01/k-elixir.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'CHONDROCOL 114 ML (CREAM)' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2019/11/hondrokolkremdljasustavov114ml.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );


$result = get_posts( array( 'post_type' => 'product-card','post_title' => 'KIDACTIVIT 120 ml syrup with lecithin' ) );

$url = 'https://altespharm.kz/wp-content/uploads/2018/02/Kidactivit-syrop.png';

$post_id = $result[0]->ID;

$tmp = download_url( $url );

$file_array = [

'name' => basename( $url ), // ex: wp-header-logo.png

'tmp_name' => $tmp,

'error' => 0,

'size' => filesize($tmp),

];

$id = media_handle_sideload( $file_array, $post_id, $desc );

if( is_wp_error( $id ) ) {

@unlink($file_array['tmp_name']);

return $id->get_error_messages();

}

@unlink( $tmp );