Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query5 = "SELECT ID FROM wp_posts WHERE post_name='".$post_id."'";
- $checkpost= mysqli_num_rows( mysqli_query($conn_link,$query5));
- //check if post exist
- if ($checkpost <= 0 && $type=="photo") {
- $query = "INSERT INTO wp_posts (post_author,post_link, post_date, post_date_gmt,post_content,post_title,post_status,post_name,post_modified,post_modified_gmt)
- VALUES ('1', '".$postlink."','".$converted_date_time."', '".$converted_date_time."', '".$content."', '".$titl."', 'publish', '".$post_id."', '".$converted_date_time."', '".$converted_date_time."')";
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Add post done <br>";
- } else
- {
- echo"No posts add";
- echo"<br>";
- echo mysqli_error($conn_link);
- }
- $query = "SELECT ID FROM wp_posts WHERE post_name='".$post_id."'";
- $row = mysqli_fetch_row(mysqli_query($conn_link, $query));
- $postid=$row[0];
- echo "post id is ".$postid."<br>" ;
- $query = "UPDATE wp_posts SET guid='http://xxxx.com/?p=".$postid."' where ID='".$postid."'";
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Done UPDATE wp_posts ";
- } else
- {
- echo"Error in UPDATE wp_posts ";
- }
- //Add image
- $query = "INSERT INTO wp_posts (post_type, guid, post_status, post_mime_type,post_parent,post_name,post_title,post_modified,post_modified_gmt)
- VALUES ('attachment', '".$actual_link."', 'inherit', 'image/jpeg', '".$postid."','".$tn."','".$tn."', '".$converted_date_time."', '".$converted_date_time."')";
- //check query
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Add image done <br>";
- echo"<br>";
- } else
- {
- echo"no image add";
- echo"<br>";
- echo mysqli_error($conn_link);
- echo"<br>";
- }
- //get image ID
- $query = "SELECT ID FROM wp_posts WHERE post_name='".$tn."'";
- $row = mysqli_fetch_row(mysqli_query($conn_link, $query));
- $imgid=$row[0];
- //add postmeta to link image to post
- $query = "INSERT INTO wp_postmeta (meta_value, meta_key, post_id)
- VALUES ('".$imgid."','_thumbnail_id', '".$postid."')";
- //check query
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Add image to post done <br>";
- } else
- {
- echo"no image add to post ";
- echo"<br>";
- echo mysqli_error($conn_link);
- echo"<br>";
- }
- //add postmeta to link image to post as _wp_attached_file
- $query = "INSERT INTO wp_postmeta (meta_value, meta_key, post_id)
- VALUES ('".$actual_link."','_wp_attached_file', '".$imgid."')";
- //check query
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Add image to post done <br>";
- } else
- {
- echo"no image add to post ";
- echo"<br>";
- echo mysqli_error($conn_link);
- echo"<br>";
- }
- //this part to link post with taxonomy
- echo"<br>";
- echo "trerm id is ".$term_id ;
- echo"<br>";
- $query7 = "SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id='".$term_id."'";
- $taxonomy_id = mysqli_fetch_row(mysqli_query($conn_link, $query7));
- $taxonomy_id=$taxonomy_id[0];
- $query = "INSERT INTO wp_term_relationships (object_id, term_taxonomy_id)
- VALUES ('".$postid."', '".$taxonomy_id."')";
- if (mysqli_query($conn_link,$query) === true)
- {
- echo"Yes INSERT INTO dmo_term_relationships Yes ";
- } else
- {
- echo"No INSERT INTO dmo_term_relationships No";
- echo"<br>";
- echo mysqli_error($conn_link);
- echo"<br>";
- }
- }
- a:5:{s:5:"width";i:640;s:6:"height";i:372;s:4:"file";s:13:"2013/03/7.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:4:{s:4:"file";s:13:"7-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:13:"7-300x174.jpg";s:5:"width";i:300;s:6:"height";i:174;s:9:"mime-type";s:10:"image/jpeg";}s:13:"helium_square";a:4:{s:4:"file";s:13:"7-640x372.jpg";s:5:"width";i:640;s:6:"height";i:372;s:9:"mime-type";s:10:"image/jpeg";}s:11:"helium_4by3";a:4:{s:4:"file";s:13:"7-400x300.jpg";s:5:"width";i:400;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:7:"480x480";a:3:{s:4:"file";s:13:"7-480x372.jpg";s:5:"width";i:480;s:6:"height";i:480;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement