get_the_terms, whether I should use string or array as the second parameter?

Question

When I running Query Monitor on one of my page, I get a notice “Array to string conversion” for the following line:

      $terms = get_the_terms( $post->ID , array( 'product-categories') );

I then check the document for get_the_terms at https://developer.wordpress.org/reference/functions/get_the_terms/, the second parameter is a string.

However, after reading further, I find some samples in the above link and some are using string directly, like below:

$terms = get_the_terms( $post->ID , array( 'teams_positions') );

but some uses an array, like below:

$post_categories = get_the_terms( $post->ID, 'category' );

So I am totally confused.

0
alancc 8 months 2021-12-07T03:05:17-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse