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


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, 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.

alancc 1 year 2021-12-07T03:05:17-05:00 0 Answers 0 views 0

Leave an answer