Title: [Plugin: Custom Content Type Manager] Pull Duplicate data
Last modified: August 20, 2016

---

# [Plugin: Custom Content Type Manager] Pull Duplicate data

 *  [prionnsias](https://wordpress.org/support/users/prionnsias/)
 * (@prionnsias)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/)
 * I would like to be able to have a page that pulls duplicate data and prints it.
   
   I am using this plugin to build teams, and what people do on these teams, i want
   another page for each team member that tells me what teams they are on, and what
   role they play. any thoughts?
 * thanks
 * [http://wordpress.org/extend/plugins/custom-content-type-manager/](http://wordpress.org/extend/plugins/custom-content-type-manager/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * (@fireproofsocks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350907)
 * Could you define what you mean by “duplicate” data?
 * Setting up the data structure for a site can take a fair amount of thought. What
   have you tried so far?
 *  Thread Starter [prionnsias](https://wordpress.org/support/users/prionnsias/)
 * (@prionnsias)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350909)
 * Hi,
    what i mean by duplicate data is basically
 * team 1
    coach – john Player – lucy ref – bill
 * team 2
    coach – Lucy Player – Bill ref – John
 * John is on 2 teams, once as a coach, another as the ref
    I want to be able to
   go to “John’s Page” and see the teams he was on and what job he did using the
   CCTM plug in i can see what each team is made up of, but i don’t know how to 
   get it to tell me what teams each person is on, and what they do on that team
 * hope that makes sense
 *  Plugin Contributor [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * (@fireproofsocks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350911)
 * If I were doing this, I would have 2 custom content types: teams, and people.
   The “team” type would use “Relation” custom fields that would let you choose 
   players and refs (i.e. “people” posts).
 * So if you view John’s page, you need to do a reverse query to see which teams
   are referencing John in any capacity. In a pseudo-query, you’d have this type
   of logic: “SELECT teams WHERE player=John OR WHERE ref=John”.
 * You can do this with WP’s querying functions, but I got so frustrated with their
   incompleteness, caveats, and lack of consistency that I wrote a separate plugin
   for this type of scenario: Summarize Posts. It’s going to be part of the CCTM
   core in the upcoming 0.9.5 version, but for now 0.7 is an independent download.
 * Using Summarize Posts, you’d want to review this:
    [http://code.google.com/p/wordpress-summarize-posts/wiki/Examples_get_posts](http://code.google.com/p/wordpress-summarize-posts/wiki/Examples_get_posts)
 * First you have to get the post_id of John’s page… this is different depending
   on whether you are inside or outside the loop (groan), but it usually is something
   like this:
 *     ```
       global $post;
       $johns_id = $post->ID;
       ```
   
 * Then you need to use $johns_id in your query. In your single-person.php theme
   file, you’d put some PHP code like this:
 *     ```
       $Q = new GetPostsQuery();
       $args = array();
       $args['post_type'] = 'team';
       $args['meta_key'] = 'player';
       $args['meta_value'] = $johns_id;
       $results = $Q->get_posts($args);
   
       foreach ($results as $r) {
          // iterates over all teams where John is a player
       }
   
       $Q = new GetPostsQuery();
       $args = array();
       $args['post_type'] = 'team';
       $args['meta_key'] = 'ref';
       $args['meta_value'] = $johns_id;
       $results = $Q->get_posts($args);
   
       foreach ($results as $r) {
          // iterates over all teams where John is a ref
       }
       ```
   
 * You may want to download the dev version of Summarize Posts, just because I’m
   in the middle of updating it, and I fixed a couple bugs since 0.7.
 * Or if you want to check out WP’s options for this, look at WP_Query() or get_posts(),
   but the basic idea is the same: you need to find the posts that have referenced
   John’s id in a custom field.
 *  Thread Starter [prionnsias](https://wordpress.org/support/users/prionnsias/)
 * (@prionnsias)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350913)
 * Wow.
    thank you very much. I need to wrap my head around this but i believe what
   your saying will work, it is just a bit beyond my current understanding of code.
   but i will give it a try thank you very much!
 *  Plugin Contributor [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * (@fireproofsocks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350915)
 * OR… you can try one of the theme functions… quite a bit simpler to follow, but
   a heavier load on the database:
 * [http://code.google.com/p/wordpress-custom-content-type-manager/wiki/TemplateFunctions#get_posts_sharing_custom_field_value](http://code.google.com/p/wordpress-custom-content-type-manager/wiki/TemplateFunctions#get_posts_sharing_custom_field_value)
 *     ```
       $results = get_posts_sharing_custom_field_value('ref', $post->ID);
       foreach ($results as $r) {
       //... do something with each
       }
       ```
   
 * The above example assumes a custom field name of “ref”, and it’ll return all 
   posts that have used the current post ID for that value (e.g. if you’re looking
   at Jeff’s page, then $post->ID will correspond to Jeff).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[Plugin: Custom Content Type Manager] Pull Duplicate data’ is closed 
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-type-manager_c9c790.
   svg)
 * [Custom Content Type Manager](https://wordpress.org/plugins/custom-content-type-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-content-type-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-type-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-type-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-type-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-type-manager/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-custom-content-type-manager-pull-duplicate-data/#post-2350915)
 * Status: not resolved