Skip to content

Instantly share code, notes, and snippets.

@cliffordp cliffordp/functions.php
Last active May 22, 2020

Embed
What would you like to do?
The Events Calendar: Include Legacy (v1) List View at the end of each post's output unless it's a TEC post or archive.
/**
* The Events Calendar: Include Legacy (v1) List View at the end of each post's output unless it's a TEC post or archive.
*
* Tested working with TEC v5.1.1.
*
* @link https://gist.github.com/cliffordp/98d438e52a1a95a9fea3e862c426b399 This snippet.
*
* @see \tribe_include_view_list() The same function used by Organizer and Venue archives in Events Calendar Pro (v1 views).
*
* @param string $content
*
* @return string
*/
function cliff_add_tec_v1_list_view_on_post_loop( $content ) {
if (
! function_exists( 'tribe_include_view_list' )
|| ! function_exists( 'tribe_is_event_query' )
|| tribe_is_event_query()
) {
return $content;
}
// We're too late to do this in the Content filter, but it's a reminder you may want to do this in your custom code.
// tribe_asset_enqueue( 'tribe-events-ajax-list' );
// Not passing 'eventDisplay' unfortunately causes PHP notices [BTRIA-378].
$args = [
'eventDisplay' => 'list',
'posts_per_page' => 3,
];
return $content .= tribe_include_view_list( $args );
}
add_filter( 'the_content', 'cliff_add_tec_v1_list_view_on_post_loop' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.