diff --git a/archive-colloquium.php b/archive-colloquium.php index 59000f5..a347365 100644 --- a/archive-colloquium.php +++ b/archive-colloquium.php @@ -39,46 +39,18 @@ ); // Get upcoming colloquia - $colloquia = get_posts( - array( - 'numberposts' => -1, - 'post_type' => 'colloquium', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $seasonstart, - 'compare' => '>=' - ) - ) - ) - ); + $colloquia = event_query(array( + 'post_type' => 'colloquium', + 'order' => 'ASC', + 'after' => $seasonstart + )); // Get upcoming miscellaneous events - $miscevents = get_posts( - array( - 'numberposts' => -1, - 'post_type' => 'miscevent', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - 'relation' => 'OR', - array( - 'key' => 'dtstart', - 'value' => $seasonstart, - 'compare' => '>=' - ), - array( - 'key' => 'dtend', - 'value' => $seasonstart, - 'compare' => '>=' - ) - ) - ) - ); + $miscevents = event_query(array( + 'post_type' => 'miscevent', + 'order' => 'ASC', + 'after' => $seasonstart + )); // Display events header and navigation ?> diff --git a/archive-concert.php b/archive-concert.php index 47a4023..55c5731 100644 --- a/archive-concert.php +++ b/archive-concert.php @@ -48,40 +48,20 @@ ); // Get archived colloquia - $colloquia = get_posts( - array( - 'numberposts' => -1, - 'post_type' => 'colloquium', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $season, - 'compare' => 'BETWEEN' - ) - ) - ) - ); + $colloquia = event_query(array( + 'post_type' => 'colloquium', + 'order' => 'ASC', + 'after' => $seasonstart, + 'before' => $seasonend, + )); // Get archived miscellaneous events - $miscevents = get_posts( - array( - 'numberposts' => -1, - 'post_type' => 'miscevent', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $season, - 'compare' => 'BETWEEN' - ) - ) - ) - ); + $miscevents = event_query(array( + 'post_type' => 'miscevent', + 'order' => 'ASC', + 'after' => $seasonstart, + 'before' => $seasonend, + )); // // Let’s start building a select menu @@ -101,61 +81,33 @@ // Set query variables for each year $querystart = $year . '0901'; $queryend = ($year + 1) . '0831'; - $query = array($querystart,$queryend); // Get archived concerts - $concertcheck = get_posts( - array( - 'numberposts' => 1, - 'post_type' => 'concert', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $query, - 'compare' => 'BETWEEN' - ) - ) - ) - ); + $concertcheck = event_query(array( + 'maxposts' => 1, + 'post_type' => 'concert', + 'order' => 'ASC', + 'after' => $querystart, + 'before' => $queryend, + )); // Get archived colloquia - $colloquiumcheck = get_posts( - array( - 'numberposts' => 1, - 'post_type' => 'colloquium', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $query, - 'compare' => 'BETWEEN' - ) - ) - ) - ); + $colloquiumcheck = event_query(array( + 'maxposts' => 1, + 'post_type' => 'colloquium', + 'order' => 'ASC', + 'after' => $querystart, + 'before' => $queryend, + )); // Get archived miscellaneous events - $misceventscheck = get_posts( - array( - 'numberposts' => 1, - 'post_type' => 'miscevent', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $query, - 'compare' => 'BETWEEN' - ) - ) - ) - ); + $misceventscheck = event_query(array( + 'maxposts' => 1, + 'post_type' => 'miscevent', + 'order' => 'ASC', + 'after' => $querystart, + 'before' => $queryend, + )); if ($concertcheck || $colloquiumcheck || $misceventscheck) { $menuitems = array_merge($menuitems, array($year)); diff --git a/front-page.php b/front-page.php index 607b991..8fb2885 100644 --- a/front-page.php +++ b/front-page.php @@ -25,63 +25,30 @@ 1, - 'post_type' => 'concert', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $today, - 'compare' => '>' - ) - ) - ) - ); + $today = date('Ymd', strtotime('now')); + + $concerts = event_query(array( + 'maxposts' => 1, + 'post_type' => 'concert', + 'order' => 'ASC', + 'after' => $today, + )); + // Get upcoming colloquia - $colloquia = get_posts( - array( - 'numberposts' => 3, - 'post_type' => 'colloquium', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'dtstart', - 'value' => $today, - 'compare' => '>' - ) - ) - ) - ); + $colloquia = event_query(array( + 'maxposts' => 3, + 'post_type' => 'colloquium', + 'order' => 'ASC', + 'after' => $today, + )); + // Get upcoming miscellaneous events - $miscevents = get_posts( - array( - 'numberposts' => 1, - 'post_type' => 'miscevent', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - 'relation' => 'OR', - array( - 'key' => 'dtstart', - 'value' => $today, - 'compare' => '>' - ), - array( - 'key' => 'dtend', - 'value' => $today, - 'compare' => '>' - ) - ) - ) - ); + $miscevents = event_query(array( + 'maxposts' => 1, + 'post_type' => 'miscevent', + 'order' => 'ASC', + 'after' => $today, + )); // Display upcoming events if ($concerts || $colloquia || $miscevents) : ?> diff --git a/page-music.php b/page-music.php index 27e13f3..6d3e7f7 100644 --- a/page-music.php +++ b/page-music.php @@ -9,26 +9,10 @@
false, - 'numberposts' => -1, + $concerts = event_query(array( 'post_type' => 'concert', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'DSC', - 'meta_query' => array(array( - 'key' => 'programme_$_embed_link', - 'value' => 'http', - 'compare' => 'LIKE' - )) + 'has_av' => true )); // access global embed variable for later diff --git a/single-member.php b/single-member.php index 079c01c..ca7db07 100644 --- a/single-member.php +++ b/single-member.php @@ -10,52 +10,18 @@ $testID = get_the_ID(); // Get archived colloquia - $colloquia = get_posts( - array( - 'numberposts' => -1, - 'post_type' => 'colloquium', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'fname', - 'value' => $testID, - ), - array( - 'key' => 'colloquium_type', - 'value' => 'HGNM Member', - ) - ) - ) - ); - - // custom filter to replace '=' with 'LIKE' - function my_posts_where($where) - { - $where = str_replace("meta_key = 'programme_$", "meta_key LIKE 'programme_%", $where); - return $where; - } - - add_filter('posts_where', 'my_posts_where'); + $colloquia = event_query(array( + 'order' => 'ASC', + 'post_type' => 'colloquium', + 'ft_composer' => $testID, + )); // Get archived concerts - $concerts = get_posts( - array( - 'suppress_filters' => false, - 'numberposts' => -1, - 'post_type' => 'concert', - 'meta_key' => 'dtstart', - 'orderby' => 'dtstart', - 'order' => 'ASC', - 'meta_query' => array( - array( - 'key' => 'programme_$_composer', - 'value' => $testID, - ) - ) - ) - ); + $concerts = event_query(array( + 'order' => 'ASC', + 'post_type' => 'concert', + 'ft_composer' => $testID + )); $upcomingcolloquia = $colloquia; $pastcolloquia = $colloquia;