-5

I am currently in a project which develops (actually re-designs) a news company website. Their old website had been developed using Wordpress (Latest version). And, now we are developing brand new custom design website using PHP and MySQL. But, they have over 10,000 news (posts) on old wordpress database. All I need to know is, how do we import all those post data to our main database? Our database and table structure is way different from wordpress one. Are there any SQL commands to import just only single or couple of columns data and paste them to another database table? Your help is highly appreciated.

PCBoy9999
  • 41
  • 1
  • 3
  • 1
    Given that the WordPress schema and your database schema are different, you'll need to create your own transformation: either through SQL scripts or perhaps a 3rd-party tool that helps with something like this. Unfortunately, the "how" is fairly broad, and we don't have any information about your database schema (and how a WordPress schema maps to it). There's really no simple answer to this. – David Makogon Aug 09 '18 at 15:20
  • There really is a simple answer, and it's mine. – Adam Aug 10 '18 at 15:33

2 Answers2

-1

Pull them down into a CSV, update the fields as required, import them into MySQL...

A CSV is a file of Comma separated values: https://en.wikipedia.org/wiki/Comma-separated_values

Plugin to get Posts as CSV: https://wordpress.org/plugins/simple-csv-xls-exporter/

Edit the field names (in a text editor or something that can edit CSVs and save them correctly), remove data you don't require etc etc. then import into your database.

Here's a handy link to import CSV into MySQL: How to import CSV file to MySQL table

Does that make sense?

Adam
  • 1,294
  • 11
  • 24
  • Wouldn't going through all of those columns in the database be a pain to mimic importing a CSV file? every table and column has to be the same or the import will fail – Isaac Aug 09 '18 at 14:53
  • Exporting to csv just seems to move the problem. This is really about migrating from one schema to another. And we have no information on the OP's new schema. CSV doesn't provide a solution, in this sense. – David Makogon Aug 09 '18 at 15:18
  • 1
    No, exporting to CSV allows the OP to restructure the data as he requires for his database, which he can then import. It's a massively simply process and probably the quickest way to do what he is asking without using script and SSH etc. – Adam Aug 09 '18 at 15:23
  • 1
    A CSV file can have the field names altered to reflect that of the new databases posts tables. Any extra data can be stripped. This can then be very simply imported using MySQL. – Adam Aug 09 '18 at 15:25
  • Indeed, but there's not a huge number of columns in the wp_posts table... https://codex.wordpress.org/Database_Description#Table:_wp_posts – Adam Aug 09 '18 at 15:25
  • 1
    You can have a csv with all the data you need, you change the field names, drop ones you don't need, and import it. It's very very simple. – Adam Aug 09 '18 at 15:26
  • 1
    I've literally done this so many times both from and to WP for many many clients. It's a quick way to solve the issue. – Adam Aug 09 '18 at 15:26
-3

If you know how to use MySQL , you make queries that can fetch the data and like that you can fetch all the data from MySQL import it in a way that you need in your new website and export it there. if You don't understand.

Step 1 : Know that is required this is very basic step, you should know what you need and make a list of it.

Step 2 : Make MySQL queries and fetch the data according to your database structure, use excel if your not so good in MySQL , organized as data as requirement

Step 3: Now you will have all the data, you can either convert that to csv or sql format and insert in to your database easily.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
Raja Osama
  • 133
  • 10