简体   繁体   中英

Wordpress - Export Featured Image mysql

I'm working on a news site that has content since 2001, and I'd like to get all posts and their featured images. However, it has a quirk, I need to have the posts and their images in the database without having to download them because they are in a blob.

How do I get this result? Should I manually copy from the database? Is there any change I have to make?

If you are going to do the current website in wordpress, I recommend to create contents in wordpress way only. These steps can be followed.

  1. Download the old website to your local environment where the new website is developing.
  2. Connect to the old website db from wordpress using wpdb

  3. Query the required contents from the old website to WordPress.

  4. Create posts/pages with contents with wp_insert_post
  5. You can convert the blob to file with the below function and save it to a temporary location file_put_contents('/path/to/new/file_name', $my_blob);
  6. Upload the file using wp_handle_upload
  7. Set it as the featured image using wp_insert_attachment

This can be executed in a loop depending upon your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM