• So I’m trying to create a “team” page template that features several types of information:

    a series a match reports (filtered by the team name- the match reports are custom post types with various post meta)
    future matches also filtered by team name (planning on using Simple event attendance plugin)
    team logo and header image
    users filtered by team name (user custom taxonomy)

    My question is what is the best way to associate the team custom post type with the user meta data of the same name?

    For example I have a team named TEAM-A. I want the players from that team to display on the TEAM-A team page.

    I am able to create the team page and the user taxonomy page separately but can’t seem to associate the two. As it stands, were another team to be created it would have to be added as both a team post type and a user team which I realise is not ideal.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I am looking for something similar – I wonder is it something possible with piklist?

    Thread Starter mantismamita

    (@mantismamita)

    There is a plugin called User taxonomies by Justin Tadlock but Im not sure if it has this functionality. Also I’ve alsready created the user taxonomies. I’ll let you know if I come up with a solution.

    Thread Starter mantismamita

    (@mantismamita)

    Here is what I have so far:

    <?php
    	$pagename = get_the_title();
        $player = get_users($args);
        	$args = array(
    	'meta_key'     => 'tm-name',
    	'meta_value'   => $pagename,
    	'meta_compare' => ''
    
     );
        foreach ($player as $user) {
            echo '<li>' . $user->display_name . '</li>';
        }
    ?>

    I think I have to put my project on hold for a while but when I get back to it I will try PODS it seems to add a lot of capabilities. ( I think the capabilities you need, if I understand you right, might not be possible in vanilla WP ). I also have a suspicion that you might be better off avoiding taxonomies and putting everything into CPT’s … but that’s a problem because WP doesnt allow you to associate CPT’s, but this is solved by pods and a couple of other plugins I think. Also you might want to have a look or ask a question on the WordPress Answers Stack Exchange site. Hope this is some help to you. Not sure that I know a lot more though unfortunately.

    shbinga

    (@shbinga)

    You could just keep a roster of user id’s in a single team page meta data. Each time you want to add a user, retrieve the key, add the user’s id to the meta and re-save it. Then use get_users to get the list, passing the meta value as the include parameter like so:

    $user_array = get_post_meta($team_id,’roster’,true);
    // join a team
    $user_array[] = get_current_user_id();
    update_post_meta($team_id,’roster’,$user_array);

    // get users on team
    get_users(array(‘include’=>$user_array));

    The include parameter should be more efficient than scanning user meta data, and if you only need a one-way association I’m not sure why you’d need custom taxonomies. Seems to me that every time you are looking for a list of users, you’re already looking at the team that they’re a part of.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Associating a custom post type with a custom (user) taxonomy’ is closed to new replies.