[wp-hackers] wp_insert_posts?

Ryan Frankel ryan.frankel at gmail.com
Wed Nov 9 21:37:50 UTC 2011


> If you've got a lot of data to import, I'd usually just use direct SQL if
> it's just the posts, or deal with the wp_insert_post() if there's other
> non-wp_posts data included.
The only reason I don't just go the wpdb route right off the bat is all of the nice escaping, validation, defaults that wp_insert_post provides.  Either way you do it is going to utilize wpdb anyways though.

> Maybe you could create a trac ticket and then do a first pass on a future bulk insert for that would meet your needs but be a starting point for a potential future wp_insert_posts()?

That sounds doable.  


ryan



> Unfortunately not. The Insert API is designed for a single post insert as
> it needs to retrieve the ID afterwards for setting post meta and
> categories/etc.
> 
> If you've got a lot of data to import, I'd usually just use direct SQL if
> it's just the posts, or deal with the wp_insert_post() if there's other
> non-wp_posts data included.
> 
> On 10 November 2011 08:12, Ryan Frankel <ryan.frankel at gmail.com> wrote:
> 
>> All,
>> Is there a function similar to wo_insert_post that can INSERT multiple
>> posts into the db at the same time (i.e. not call INSERT over and over)?  I
>> have thousands of posts to insert into my db from an API pretty often and
>> it looks like the long pole in the execution time is all of the inserts.
>> It would be nice to have a function like wp_insert_posts for multiple post
>> additions using multiple VALUEs that mysql supports.  I realize I can
>> probably modify the wp_insert_post code to do it but I figured I would ask
>> so I don't reinvent the wheel.
>> 
>> ryan
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list