Support » Fixing WordPress » wp_get_object_terms returning an empty array

  • I have the following code:

    $objects = get_posts( array( 'post_type' => 'negocio', 'zona' => get_query_var( 'zona' ), 'posts_per_page' => -1, ) );
    $objects_ids = wp_list_pluck( $objects, 'ID' );
    $categorias = wp_get_object_terms( $objects_ids, 'categoria' );

    I’m sure that $objects_ids has at least one ID and the taxonomy ‘categoria’ exisist and it should have at least on taxonomy. (every object hast at least on taxonomy of type zona and one taxonomy of type categoria).

    The problem is that I’m getting an empty array. I’m not sure if the problem is actually related to this piece of code or maybe to a plugin or something else.

    How can I debug this? I usually use a bunch of $print_r to check the results on everything but in this case I think that I need to go deeper to find out the issue.

    Any ideas or comments are welcome.

  • The topic ‘wp_get_object_terms returning an empty array’ is closed to new replies.