2014-08-27 130 views

回答

1

基本上你所要做的就是在Wordpress的wp_posts表中插入你的記錄。該表具有以下字段(如果你使用最新的3.9.2版本,當然):

ID - (no explanation needed, it is auto-increment value) 
post_author - (here in your case put 1 - this is Administrator account) 
post_date - (no explanation needed) 
post_date_gmt - (same as above, but date is GMT) 
post_content - (your article content, HTML code, if any, may or may not be escaped) 
post_title - (no explanation needed) 
post_excerpt - (can be empty in your case) 
post_status - (there are six of them, in your case put "publish" or "draft" if you want manually to make post visible at later stage) 
comment_status - (put "closed" if you want to disable comments or "open" otherwise) 
ping_status - (same as above, but it applies for ping) 
post_password - (put empty string) 
post_name - (put lowercase converted post title, but replace spaces with "-", this is URL friendly version of the post name, ex: my-first-post-title) 
to_ping - (put empty string) 
pinged - (put empty string) 
post_modified - (put date of the post) 
post_modified_gmt - (same as above, but date is GMT) 
post_content_filtered - (put empty string) 
post_parent - (put 0 initially, later you can build your post hierarchy) 
guid - (URL of the post, http://www.yourdomain.com/?page_id=the_ID_of_the_post) 
menu_order - (put 0) 
post_type - (put "page" or "post", there is a difference though) 
post_mime_type - (put empty string) 
comment_count - (put empty string) 

這裏是例如SQL查詢與插入成功所需的最低值:

INSERT INTO wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt, 
post_status,comment_status,ping_status,post_password,post_name,to_ping,pinged, 
post_modified,post_modified_gmt,post_content_filtered,post_parent,guid, 
menu_order,post_type,post_mime_type,comment_count) 
VALUES (1,'2014-08-28 02:00:00', '2014-08-28 00:00:00','<h1>Some content</h1>', 
'My first post','Some excerpt','publish','closed', 'closed','','my-first-post', 
'','','2014-08-28 02:00:00', '2014-08-28 00:00:00','',0, 
'http://127.0.0.1/wordpress/?page_id=2000',0,'post','','') 

記住,您的表wp_posts可能有一個前綴。

+0

謝謝你的努力,它幫助了我很多。 – 2014-08-27 10:47:06