$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>mysql - How to create a post based on data in a table?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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...);
Post a comment

comment list (0)

  1. No comments so far