Created
October 2, 2012 02:34
-
-
Save codearachnid/3815849 to your computer and use it in GitHub Desktop.
Fix compatibility issues with The Event Calendar and Posts 2 Posts WordPress Plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
*/ | |
function tribe_to_p2p_pre_get_posts_20121001( $query ){ | |
if(isset($query->_p2p_capture) && $query->_p2p_capture) { | |
add_filter( 'posts_fields', 'tribe_to_p2p_setupFields_20121001', 20); | |
} else { | |
remove_filter( 'posts_fields', 'tribe_to_p2p_setupFields_20121001', 20); | |
} | |
return $query; | |
} | |
function tribe_to_p2p_setupFields_20121001( $fields ){ | |
global $wpdb; | |
$fields = "{$wpdb->posts}.ID"; | |
return $fields; | |
} | |
add_action( 'pre_get_posts', 'tribe_to_p2p_pre_get_posts_20121001'); |
Thanks for this! I found that I also needed to add:
$query->query_vars['eventDisplay'] = 'custom';
under the add_filter call.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I put this in my functions.php file after having issues with the many-to-many relationship in Posts 2 Posts connections when using Event Calendar and it worked like a charm.