im kinda new in wordpress and this is the problem im facing:

I've created a custom div with 3 tabs that displays 3 inner containers, each tab is for a a specific "Category". For Example, let's call the categories cs:go, cod and fifa. What I want to do is to put thumbnails of a specific cathegory that links you to a profile page.

Example: inside the "cs:go" tab I want to put 5 thumbnails, one for each player, that links to a specific profile page for each. Same for COD and for FIFA.

  • so the thumbnails are the categories or the posts featured images? – rudtek Oct 27 '17 at 17:36

You should provide some codes to help understand your issue.

I'll guess here that you want to display in each category the users who play the game. So you need first to assign to each player the category they play. In the register_taxonomy function, this is done by adding 'user' in the second parameter.

As they're is no automatic UI to assign categories to user (that I know of), you need to add your own by using multiple hooks

    //when editing another user profile (e.g. for admin)
    add_action('edit_user_profile', 'my_user_display_edit_form');
    //when editing your own profile
    add_action('show_user_profile', 'my_user_display_edit_form');
    //when creating a new user
    add_action('user_new_form', 'my_user_display_edit_form');

    //when saving another user profile (e.g. for admin)
    add_action('edit_user_profile_update', 'my_user_save_meta');
    //when saving your own profile
    add_action('personal_options_update', 'my_user_save_meta');
    //after a new user as been created
    add_action('user_register', 'my_user_save_meta');

I leave the implementation of my_user_display_edit_form and my_user_save_meta to you. (see wp_get_object_terms() and wp_set_object_terms() documentation)

Then you can get a list of users ID by term using get_object_in_term() coupled with get_users()

    $ids = get_object_in_term($term_id, $taxonomy);
    $users = get_users(['include' => $ids]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.