Skip to content

Instantly share code, notes, and snippets.

@elimn
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elimn/a5843c2723a04866e593 to your computer and use it in GitHub Desktop.
Save elimn/a5843c2723a04866e593 to your computer and use it in GitHub Desktop.
MT | TEC | Adds the "WP Admin > Events: Upcoming" page, which only shows upcoming events
<?php
// Adds upcoming menu item to WP Admin Menu
function tribe_custom_admin_menu () {
add_submenu_page(
'/edit.php?post_type='.TribeEvents::POSTTYPE,
'Events: Upcoming',
'Events: Upcoming',
apply_filters( 'tribe_settings_req_cap', 'manage_options' ),
'edit.php?post_type='.TribeEvents::POSTTYPE.'&orderby=start-date&order=asc&upcoming-events=true'
);
}
add_action( 'admin_menu', 'tribe_custom_admin_menu', 1 );
// Adds Upcoming Events Page
function tribe_custom_events_search_orderby ( $orderby_sql ) {
global $ecp_apm;
if (!empty($_GET['upcoming-events']) && get_query_var('post_type') == TribeEvents::POSTTYPE) {
$ecp_apm->filters->add_active(
array('ecp_end_date' =>
array(
'value' => date('Y-m-d'),
'is' => 'gte',
'is_date_field' => true
)
)
);
}
return $orderby_sql;
}
add_filter('posts_orderby', 'tribe_custom_events_search_orderby', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment