0

Is it normal for wp_set_post_terms() to be very slow?

When wp_insert_post() it takes about 1 second. Adding 4 wp_set_post_terms() 7 - 10 seconds to the operation.

Pseudo code example:

$values = ['value_1', 'value_2', 'value_3', 'value_4', 'value_5', 'value_6'];

$post_id = '1234';
$taxonomy = 'offerings';

wp_set_post_terms( $post_id, $values, $taxonomy );
wp_set_post_terms( $post_id, $values, $taxonomy );
wp_set_post_terms( $post_id, $values, $taxonomy );
wp_set_post_terms( $post_id, $values, $taxonomy );
  • Why would you call something like this? – Fabian Marz Sep 18 '18 at 23:51
0

I've recently done a batch import of about 200 posts, with 5 taxonomies attached to them and each of the posts a few terms. It took about 5-10 seconds to do the whole batch.

So no, it shouldn't be this slow.

  • I tried to use tax_input as part of wp_insert_post() and it worked way better performance wise. Pretty much same as wp_insert_post() without tax_input. – Cudos Sep 19 '18 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.