A
A
Alex2018-06-25 13:31:13
WordPress
Alex, 2018-06-25 13:31:13

How to programmatically create multiple comments in WordPress?

There is an array with data for comments. There can be a lot of (for 700 pieces) elements in an array. And if I just iterate over each using wp_new_comment()then I run into 504 Gateway Timeout. Is there a way to add an array of comments in one go? Or do it somehow faster?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Ba An Doan, 2018-06-25
@doanbaanh

You need to set a higher fastcgi_read_timeout value in the nginx settings

A
Alexander Sobolev, 2018-06-25
@san_jorich

You can also figure out which tables which data WP adds when creating a comment, and write a script that writes the whole thing right away to the database with the condition that the previous iteration in the cycle is performed, or with a small time delay.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question