mysql - How to create a post based on data in a table?

admin2025-06-02  1

I have a MySQL table which I created that contains fields for a Title and a Body. There about 100 records in this table. I would like to create a Wordpress post for each row in this table. Is that possible with a plugin? I was thinking I could use the email to post feature but it seems like a workaround. Ideally I would like this process to be repeatable through a Cron job IE: every night import the new posts. Thank you!

I have a MySQL table which I created that contains fields for a Title and a Body. There about 100 records in this table. I would like to create a Wordpress post for each row in this table. Is that possible with a plugin? I was thinking I could use the email to post feature but it seems like a workaround. Ideally I would like this process to be repeatable through a Cron job IE: every night import the new posts. Thank you!

Share Improve this question edited Sep 8, 2015 at 3:12 AAA asked Sep 8, 2015 at 2:47 AAAAAA 1251 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

yes that's possible, you can create your custom post type and use MySQL query to fetch from csv file, and use insert into post function within the loop. you can use LOAD DATA INFILE query to fetch from excel and then use wp insert post function to insert into db. the query will look like:-

LOAD DATA LOCAL INFILE 'abc.csv' INTO TABLE abc
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(col1, col2, col3, col4, col5...);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748848681a314229.html

最新回复(0)