I have nearly 10,000 rows in my _p2p table and have been using P2P almost since the very beginning. During that time, there have been API and storage changes, in addition to me making multiple site changes. Over that period, my calls to register relationships have changed. Sometimes one post type was ‘from’ and another time it was ‘to’. At this point, I have nearly 20 calls to p2p_register_connection_type in my code.
My problem is that with my current setup, only some of my connections are being returned correctly. For example, I have post types ‘club’ and ‘player’ (talking about soccer teams). I connected 43 players to a specific club, but when I make the call to WP_Query, it returns zero results. If I check the SQL code from that query and change the ‘p2p_from’ and ‘p2p_to’ fields, all 43 players are correctly returned, so I know that the information is still correct in my database.
My problem is that while I can change the ‘from’ and ‘to’ in my p2p_register_connection_type and it returns the 43 players correctly, my issue is that in some cases, the original ‘from’ and ‘to’ return the correct results. Over time, I hadn’t paid attention to the ordering of my registration fields because I assumed that with the reciprocal field on, it wouldn’t matter one bit. Now it is coming back to bite me in the butt.
Am I going to need to write a script to go through and change each connection one by one to make sure that ‘player’ is always in the ‘from’ field and ‘club’ is in the ‘to’ field? It seems like this issue should be able to be resolved with some changes to the SQL calls, but that may result in less efficient queries.
- The topic ‘[Plugin: Posts 2 Posts] Reciprocal Problem’ is closed to new replies.