Can content in a mysql database table be imported into a website using WIKI plugin?

As website owner I am constantly trying to add new valuable content to my website. I have a database table with few 1000 records, each with valuable information. I wanted to figure out if this can be imported into a WIKI.

I had asked about this a few weeks ago to the support staff at WPMUDEV and came to know there are no specific feature that can do this. Of course this cannot be done since the data in each database table will be different. Digging into the wordpress DB I found out that each wiki was nothing more than a post of type ‘incsub_wiki’.

So I wrote my own SQL script to convert the data from that table into individual WIKI’s.

Warning: If you are not familiar with mysql its better not to try this. I am implementing this on a fresh install of wordpress so even if I screw up I am not going to be very upset. If you have a full blown wordpress site with few 100s-1000s post already, I wouldn’t advice you try this at home. :slight_smile:

INSERT INTO wp_posts (
1 As post_author,
NOW() As post_date,
ADDTIME(NOW(), '0 5:0:0.000000') As post_date_gmt,
'Name: <strong><a target=_blank rel=nofollow title=',TRIM(name),' href=',Weblink,'>',name,'</a></strong><br />',
'Website: <strong><a target=_blank rel=nofollow title=',TRIM(name),' href=',Weblink,'>',Weblink,'</a></strong><br />',
'City: <strong>',TRIM(city),'</strong><br />',
'State: <strong>',TRIM(state),'</strong><br />',
'Number of Foreign Medical Graduates: <strong>',fmg,'</strong><br />',
'Contact: <strong>',REPLACE(contact,',','<br />'),'</strong><br />',
'<h2>Additional Comments</h2>',
) As post_content,
TRIM(name) As post_title,
'' As post_excerpt,
'publish' as post_status,
'open' As comment_status,
'open' As ping_status,
'' As post_password,
REPLACE(TRIM(name),' ','-') As post_name,
'' As to_ping,
'' As pinged,
NOW() As post_modified,
ADDTIME(NOW(), '0 5:0:0.000000') As post_modified_gmt,
'' As post_content_filtered,
0 As post_parent,
'' As guid,
0 As menu_order,
'incsub_wiki' As post_type,
'' As post_mime_type,
0 As comment_count
FROM Table_Name;

UPDATE wp_posts SET guid=id;

Here are the columns in the wp_posts table you should be paying attention to,

post_author – Self Explanatory, value is usually 1 for admin user,

post_date – Self Explanatory,

post_date_gmt – Post Date Time in GMT,

post_content – Very important field. You post content. What ever you add to this field will show up on the post. If your database table has a several columns you can show them all using CONCAT operator. See my example above.

post_title – Important field – Title of your Post,

post_status – Important field, value should be “publish” for the post to be published,

comment_status- Self Explanatory, value should be “open”,

ping_status- Self Explanatory, value should be “open”,

post_name – This is different from post_title. This is used by the URL,

post_modified-Self Explanatory,

post_modified_gmt-Self Explanatory,

post_parent-Not sure what this does, but value should be 0,

guid-Important field, should be same as post ID, This field is used as the post id in URL

menu_order-Not sure what this does, but value should be 0,

post_type – Very important field, This has to be ‘incsub_wiki’. This defines this post is of type WIKI.

comment_count – Self Explanatory, set value to 0.

Your data might need some cleaning for empty spaces etc. After all the data cleansing the above insert would have created lots of WIKI’s, meaning if I had 1000 records in my mysql table, after this insert I will now have 1000 WIKI pages on my website. Cool huh?

If you have any questions let me know.