• Hi, I am trying to import a database that is not a wordpress database. I want my theme to call the database as posts. this is what the database looks like:

    CREATE TABLE dump_music_lyrics (
    id int(11) NOT NULL DEFAULT ‘0’ COMMENT ‘Unique Identifier’,
    a_name varchar(150) NOT NULL COMMENT ‘Artist / Band Name’,
    a_tag varchar(1) NOT NULL COMMENT ‘Artist Tag’,
    a_album varchar(150) DEFAULT NULL COMMENT ‘Album Name’,
    a_album_year varchar(4) DEFAULT NULL COMMENT ‘Album Year’,
    a_song varchar(150) DEFAULT NULL COMMENT ‘Song Title / Track Name’,
    a_lyrics text COMMENT ‘Song Lyrics’
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    How can I change anything I need to to make it work? I tried changing them all to like rather than “a_song” it read “post_title” and then tried importing it, no luck. Any idea?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ll need to write a custom script that will parse what you have and turn it into posts.

    So, here’s a suggestion based on how I’d do it.
    1. Insert your existing table into your WP database.
    2. Use PHP to retrieve everything from that table
    3. Use a while loop on the results. Insert each result as a new WP post (wp_insert_post) with the a_lyrics as content and a_song as title. Then insert all other fields as custom value (add_post_meta)
    4. Delete the row you just inserted from the dump_music_lyrics table – in case the script times out, you won’t need to worry about duplicates.

    Thread Starter danielfein

    (@danielfein)

    Can you help me do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Import Non-WordPress Database’ is closed to new replies.