Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // template
- $event_args = array(
- 'post_type' => 'event',
- 'type' => 'yearly',
- 'format' => 'custom',
- 'echo' => 0,
- 'show_post_count' => 1,
- 'before' => '--><li>',
- 'after' => '</li><!--',
- );
- $event_years = wp_get_archives( $event_args );
- $events = str_replace( $home_url, $home_url . '/races', $event_years );
- $minus_post_type = str_replace( '?post_type=event', '', $events );
- $context[ 'race_years' ] = '<ul class="list-inline list-races"><!--';
- $context[ 'race_years' ] .= str_replace( date( 'Y' ) . '/', '', $minus_post_type );
- $context[ 'race_years' ] .= '--></ul>';
- $context[ 'title' ] = post_type_archive_title( '', false );
- array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
- // alter query - front-end race archive lists
- function alter_query_for_races( $query ) {
- if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'event' ) ) {
- // @TODO: meta query on event date, not publication date
- $query->set( 'posts_per_page', '25' );
- if ( ! is_year() ) {
- $query->set( 'year', date( 'Y' ) );
- }
- // if ( ! is_year() ) {
- // $query->set( 'meta_query', array(
- // array(
- // 'key' => '_event_start_date',
- // 'value' => array('2017-01-01','2017-12-31'),
- // 'compare' => 'BETWEEN',
- // ),
- // ) );
- // }
- if ( get_query_var( 'continent' ) ) {
- $query->set( 'meta_query', array(
- array(
- 'key' => 'idf_continent_selector',
- 'value' => get_query_var( 'continent' ),
- ),
- ) );
- }
- }
- }
- add_action( 'pre_get_posts', 'alter_query_for_races' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement