Title: [Plugin: Posts 2 Posts] Querying connections by their fields ?
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Querying connections by their fields ?

 *  Resolved [dor](https://wordpress.org/support/users/dor/)
 * (@dor)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-querying-connections-by-their-fields/)
 * Thank you, scribu, for the work! Now, following my stackexchange question i run
   into a problem.
 * I’ve registered this connection:
 *     ```
       p2p_register_connection_type( array(
           'id' => 'pieces_persons',
           'from' => 'piece',
           'to' => 'person',
   
           'fields' => array(
             'role' => array(
               'title' => 'Role',
               'values' => array( 'conductor', 'composer', 'soloist' )
             )
           )
         ) );
       ```
   
 * I’ve created a `piece`, added two persons: one `conductor` and one `composer`.
   And I want to get only `conductor` for current post:
 *     ```
       $conductor = p2p_type( 'pieces_persons' )->get_connected( get_queried_object_id(), array(
           'connected_meta' => array( 'role' => 'conductor' )
         ) );
         echo count( $conductor->posts );
       ```
   
 * But this echoes `2` — i get both persons.
 * Please, what’s wrong?
 * Thanks!

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

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-querying-connections-by-their-fields/#post-2369307)
 * It’s a bug; thanks for reporting. Try the [development version](http://downloads.wordpress.org/plugin/posts-to-posts.zip).
 *  Thread Starter [dor](https://wordpress.org/support/users/dor/)
 * (@dor)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-querying-connections-by-their-fields/#post-2369308)
 * Wow, thank you. I’ll try and respond.
 *  Thread Starter [dor](https://wordpress.org/support/users/dor/)
 * (@dor)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-querying-connections-by-their-fields/#post-2369309)
 * Yes, thank you!

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

The topic ‘[Plugin: Posts 2 Posts] Querying connections by their fields ?’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [dor](https://wordpress.org/support/users/dor/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-querying-connections-by-their-fields/#post-2369309)
 * Status: resolved