• I’m not sure that this is possible with a taxonomy, but I was hoping to get some feedback on the best way to store my data. My site is storing information about soccer players and teams. I have a team custom post type and a player custom post type. My team page shows all of the related players, based on Posts to Posts data previously entered.

    My problem is that in the future, when players change teams, there isn’t any way to store any kind of time related data with the existing relationship. For example, at a minimum, I’d love to be able to store some sort of tag ‘current’, so that way my team page could show the current team as well as a list of all players. Even better would be storing the years that a player was a part of the team.

    I was thinking that perhaps the taxonomy description would be a place to store that information without having to create new tables or fields. I could maybe serialize some information and put it in as part of the connection process. Does that sound like a good way to accomplish what I’m trying to do? The API might then be changed to have an optional filter based on the information stored in the description.

    While I’m writing this, I’m still brainstorming how to make it functional. I’m thinking that in P2P metabox, after you create a connection, there could be a little button added that would allow you to edit the relationship description. That wouldn’t require much of an interface than a text area, and you just assume that the developer putting data in there would also know how to read it out.

    I haven’t looked super closely at the actually hidden taxonomy, so it might not even be feasible given the current setup. Thoughts?

Viewing 15 replies - 61 through 75 (of 77 total)
  • Regarding duplication, there are two ways to achieve the multiple-role scenario

    I would go with A… in that case a single query works…

    Plugin Author scribu

    (@scribu)

    while($sc_query->have_posts()):$sc_query->the_post();
    
      $sc_output = '';
      $sc_output .= '<li><a href="' . get_permalink($post->ID) . '">';
      $sc_output .= $post->post_title;
    
      $sc_output .= ' ' . p2p_get_meta( $post->p2p_id, 'date', true );
    
      $sc_output .= '</a></li>';
    
    ...
    endwhile;

    Obviously, replace ‘date’ with your meta key.

    great!!!

    and does this still work:

    $my_query = new WP_Query( array(
        'post_type' => 'book',
        'connected_to' => 'any',
        'connected_meta' => array(
            'connection_date' => 'long ago',
        )
    ) );
    Plugin Author scribu

    (@scribu)

    In the time it took you to ask that question, you could have just tried it and see for yourself.

    well, I actually did before I asked but it didn’t work out…
    so I presumed something might be wrong with my code ergo – the question

    Plugin Author scribu

    (@scribu)

    It works for me. Try 'connected_from' => 'any'.

    if the metadata value of the field in the query contains diacritics – the search returns nothing.

    that’s why it didn’t work.

    Plugin Author scribu

    (@scribu)

    Good to know.

    Plugin Author scribu

    (@scribu)

    To allow duplicate connections:

    0. Re-download the development version.

    1. Add 'prevent_duplicates' => false to p2p_register_connection_type():

    p2p_register_connection_type( array(
    	'from' => 'post',
    	'to' => 'page',
    	'prevent_duplicates' => false,
    ) );

    will the pre-exiting connections stay intact?

    after some testing – from what i see – they will

    Scribu, is there a way to use this with your front end editor?

    Plugin Author scribu

    (@scribu)

    Erm, I don’t understand what you mean. Also, please open a new topic.

    Hi scribu! Is it posible to join wp_p2pmeta in the WP_Query? Because the only way that I found to access to meta_value field is to call p2p_get_meta() in the loop. But each call of p2p_get_meta() is a new query to de DB…
    It is only a little doubt, your plugin it is terrible!

    Plugin Author scribu

    (@scribu)

    My plugin is terrible? Gee, thanks…

    I suppose I should query all the p2p meta in one go.

Viewing 15 replies - 61 through 75 (of 77 total)
  • The topic ‘[Plugin: Posts 2 Posts] How To Add Info to Connection’ is closed to new replies.