Last active
January 6, 2016 20:49
-
-
Save codearachnid/5835762 to your computer and use it in GitHub Desktop.
This is a custom query fix for The Events Calendar plugin to query other post types in the same loop as events. This also works with TEC PRO for recurrence.
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 | |
/** | |
* setup when your post type is saved to add _EventStartDate & _EventDuration | |
* meta fields add your own post types (line 10) to mach filters for the meta | |
* data. Then use tribe_get_events to query both all desired post types (be | |
* sure to set for future status) | |
*/ | |
function extend_events_startdate( $post_id ){ | |
//verify post is not a revision | |
if ( !wp_is_post_revision( $post_id ) && in_array( get_post_type( $post_id ), array( 'post' ) ) ) { | |
$get_post = get_post($post_id); | |
update_post_meta( $post_id, '_EventStartDate', $get_post->post_date ); | |
update_post_meta( $post_id, '_EventDuration', 86400 ); | |
} | |
} | |
add_action( 'save_post', 'extend_events_startdate' ); | |
// example usage | |
$events = tribe_get_events( array('post_type' => array('post','tribe_events'), 'post_status' => array( 'future', 'publish' ))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment