1

My question is similar to that one which was closed for being too broad, so I'll try to be clearer.

What I have: a sqlite database (single table) containing over 50'000 posts (with fields like author, content, date, etc.). It stems from scraping a huge static, html-only website.

What I want to achieve: displaying those posts in a standard WP installation.

My approach: I would

  1. Initialize an empty WordPress website
  2. Write a script that reads a post from the original DB and writes it into the corresponding fields of the WP database (ID -> ID, author -> author, date -> date, ...)
  3. Run the WordPress engine engine and expect the posts to appear

My question: is this approach likely to succeed, or should I avoid this futile work and consider other solutions?

1 Answer 1

1

I don't see any reason for this not to work. I have done similar transfers few times, and if you transfer all data correctly, and if posts in the wp_posts are well formed, with all data present (status, type...), it will work.

The tricky part might be the data that can't fit into wp_posts, and it should go into wp_postmeta, you need to take care of proper post ids. Also, make sure to use correct format for date field, make sure to have both post_date and post_date_gmt filled, guid (some unique string for each post, WP uses URL by default), and make sure author ID's are correct.

2
  • I'd personally not work on the raw tables, but use WP's wp_insert_post and friends, so WP will take care of everything else, but it should work just as fine working directly on the tables.
    – janh
    Oct 20, 2017 at 15:45
  • If you have a lot of posts, it is better to use direct SQL approach, it will be much faster. But, nothing wrong with wp_insert_post for something like this. Oct 20, 2017 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.