• I’ve created custom user taxonomies, I’ve got users associated with them, I can see the associations in the database, they’re editable from the user profile page, they show up in the custom taxonomy count, they’re there…

    When I try to get_the_terms… nada.

    Here’s what I’ve got:

    $users = new WP_User_Query( array( 'role' => 'Subscriber' ) );
    foreach ( $users->results as $user ) : setup_postdata($user);
                    $terms = get_the_terms($user->ID, 'MyTaxonomy');
                              if ($terms) foreach ($terms as $term) {
                                           echo $term->slug . ' ';
                               }
    
    ////////// a bunch of other stuff ////////////////
Viewing 1 replies (of 1 total)
  • I have not tried it, but you might need get_object_terms() instead of get_the_terms(). I think get_the_terms() only works on post types while get_object_terms works on any object type.

Viewing 1 replies (of 1 total)
  • The topic ‘get_the_terms not working’ is closed to new replies.