Import images from old WordPress site into new site
I have exported both tables from old wordpress site of which gallery images i want to import into new wordpress site.
After export, i follow following steps:
–> In the wp_posts.sql file I did the following:
-
First I change all the INSERT INTO sentences to INSERT IGNORE INTO in case duplicate keys exists It don’t break them
-
I modified all image urls to match new domain (not always needed, depending where you are importing from)
-
I removed all unnecessary SQL code such as ALTER TABLE and INSERT TABLE and just left the INSERT INTO SENTENCES
Ziped the file and imported into new site db with phpmyadmin–> In the wp_postmeta.sql file I did the following:
- I removed all the unnecessary SQL code such as ALTER TABLE and INSERT TABLE and just left the INSERT INTO SENTENCES
- I changed all the INSERT INTO
wp_postmeta
(meta_id
,post_id
,meta_key
,meta_value
) VALUES to INSERT INTOwp_postmeta
(post_id
,meta_key
,meta_value
) VALUES . Basically Im removing meta_id because I want to insert all the postmeta at the end of the table and use the auto increment - I did a regex search and replace to remove all ID from values. I used ( ([0-9]+), and replaced with just (
Zipped file and imported to new site
–>The last step is to copy the image files into the wp-content/uploads/
–>Before import these tables into new wordpress database, i removed Create Table code from both files to avoid exiting table error.
–> Both tables successfully imported, but in media folder images have not reflected. It is only showing demo images of theme installed and activated.
Kindly provide solution in this case.
Thanks
Leave an answer