WordPress.org

Ready to get started?Download WordPress

Forums

get_the_terms not working (2 posts)

  1. derol
    Member
    Posted 11 months ago #

    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 ////////////////
  2. vtxyzzy
    Member
    Posted 11 months ago #

    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.

Reply

You must log in to post.

About this Topic