scribu / wp-posts-to-posts

Efficient many-to-many connections between posts, pages, custom post types, users.
http://wordpress.org/plugins/posts-to-posts/
975 stars 261 forks source link

Getting a SQL error when using with Event Expresso #528

Open deckchairuk opened 8 years ago

deckchairuk commented 8 years ago

Hello,

I am using Posts 2 Posts to create some connections to event expresso events but for some reason I'm getting this error:

WordPress database error: [Operand should contain 1 column(s)] SELECT SQL_CALC_FOUND_ROWS tl_posts.*, tl_p2p.* FROM tl_posts INNER JOIN tl_p2p WHERE 1=1 AND tl_posts.post_type = 'abstracts' AND (tl_posts.post_status = 'publish' OR tl_posts.post_status = 'cancelled' OR tl_posts.post_status = 'postponed' OR tl_posts.post_status = 'sold_out' OR tl_posts.post_status = 'acf-disabled' OR tl_posts.post_status = 'private') AND (tl_p2p.p2p_type = 'abstracts_to_espresso_events' AND tl_posts.ID = tl_p2p.p2p_from AND tl_p2p.p2p_to IN (SELECT tl_posts.ID, tl_esp_event_meta.* FROM tl_posts LEFT JOIN tl_esp_event_meta ON ( tl_esp_event_meta.EVT_ID = tl_posts.ID ) WHERE 1=1 AND tl_posts.ID IN (315) AND tl_posts.post_type = 'espresso_events' AND (tl_posts.post_status = 'publish' OR tl_posts.post_status = 'cancelled' OR tl_posts.post_status = 'postponed' OR tl_posts.post_status = 'sold_out' OR tl_posts.post_status = 'acf-disabled' OR tl_posts.post_status = 'private') ORDER BY tl_posts.post_date DESC )) ORDER BY tl_posts.post_date DESC LIMIT 0, 10

Does anyone know what could be causing this? With debug off it just shows nothing, on both the backend and frontend.

Thanks, Harry.

meloniq commented 8 years ago

Thread that may help: https://wordpress.org/support/topic/plugin-posts-2-posts-operand-should-contain-1-column

deckchairuk commented 8 years ago

Hey Meloniq, thanks for you're reply.

I did have a look into that but it didn't fix the issue. I'm using Event Expresso, that fix is for Tri.be's event calendar annoyingly - although I'd of thought it should work with both.

Thanks, Harry.

deckchairuk commented 8 years ago

I've found what's causing the issue from this post; https://eventespresso.com/topic/php-error-in-logs/.

It looks like this; SELECT tl_posts.ID, tl_esp_eventmeta., is what is causing the issue. I tried the query in sequel pro after removing the tl_esp_eventmeta. part and it works fine.

My next task is how I can customise the plugin query, I've found where the plugin is adding this part to the query which is this part; $part .= " AND $wpdb->p2p.$to IN ($search)";.

Would anyone be able to tell me how I can edit this without updates breaking the plugin? (even though there aren't any as he's stopped support).

Thanks.