You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WordPress database error: [Operand should contain 1 column(s)]
upon further review it turns out that the bug was being created by another plugin, Tri.be's The Event Calendar (side note: which I'm a dev for). We are doing a major overhaul of our plugin's query structure that will fix this issue down the line. In the interest of suggesting a clean way to prevent this from happening to older versions of our plugin or other plugins that might be cluttering WP_Query with custom fields, I submit this simple filter to ensure the nested select only has 1 column.
<?php/** * Fix compatibility issues with The Event Calendar and Posts 2 Posts WordPress Plugins * Issue arrises with how nested select queries function when P2P expects a single column. */functiontribe_to_p2p_pre_get_posts( $query ){
if(isset($query->_p2p_capture) && $query->_p2p_capture) {
add_filter( 'posts_fields', 'tribe_to_p2p_setupFields', 20);
} else {
remove_filter( 'posts_fields', 'tribe_to_p2p_setupFields', 20);
}
return$query;
}
functiontribe_to_p2p_setupFields( $fields ){
global$wpdb;
$fields = "{$wpdb->posts}.ID";
return$fields;
}
add_action( 'pre_get_posts', 'tribe_to_p2p_pre_get_posts');
I ran into an interesting DB error:
WordPress database error: [Operand should contain 1 column(s)]
upon further review it turns out that the bug was being created by another plugin, Tri.be's The Event Calendar (side note: which I'm a dev for). We are doing a major overhaul of our plugin's query structure that will fix this issue down the line. In the interest of suggesting a clean way to prevent this from happening to older versions of our plugin or other plugins that might be cluttering WP_Query with custom fields, I submit this simple filter to ensure the nested select only has 1 column.
Source: https://gist.github.com/3815849
The text was updated successfully, but these errors were encountered: