/** * Include the List view * * Accepts an array of query arguments, retrieves them, and returns the html for those events in list view * * Optional inline example: * < code > * <?php * echo myfunction(); * ?> * </ code > * * @category Events * * @param array $args Args to be passed to Tribe__Events__Query::getEvents() * @param bool $initialize Whether the list view template class needs to be included and initialized * * @return string **/ function tribe_include_view_list($args = null, $initialize = true) { global $wp_query; // hijack the main query to load the events via provided $args if (!is_null($args) || !($wp_query->tribe_is_event || $wp_query->tribe_is_event_category)) { $reset_q = $wp_query; $wp_query = Tribe__Events__Query::getEvents($args, true); } // single-event notices are jumping in on this init when loading as a module Tribe__Events__Main::removeNotice('event-past'); // get the list view template ob_start(); if ($initialize) { tribe_initialize_view('Tribe__Events__Template__List'); } tribe_get_view('list/content'); $list_view_html = ob_get_clean(); // fix the error of our ways if (!empty($reset_q)) { $wp_query = $reset_q; } // return the parsed template return $list_view_html; }