title(); if(get_field('top_level_club_page')){ // get clubs news $posts = array( 'post_type' => 'post', 'post_status' => array('publish'), 'posts_per_page' => 4, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'related_club', 'value' => '"' . get_the_ID() . '"', 'compare' => 'LIKE' ), array( 'key' => 'related_club', 'compare' => '=', 'value' => '', ) ) ); $context['news'] = Timber::get_posts($posts); wp_reset_postdata(); $template = 'single-club.twig'; $clubSubPages = array( 'youth-and-community', 'sports-and-recreation', 'gym-fitness', 'facilities', ); $clubID = $post->ID; $tiles = array(); foreach ($clubSubPages as $tilePage){ $args = array( 'name' => $tilePage, 'post_type' => 'club', 'post_status' => 'publish', 'post_parent' => $clubID, ); $the_query = new WP_Query( $args ); // use WP_QUERY becuase of bug with query_posts if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $tiles[$tilePage] = $post; } /* Restore original Post Data */ wp_reset_postdata(); } } wp_reset_postdata(); $context['tiles'] = $tiles; // promotions $promotions = array( 'post_type' => 'promotion', 'post_status' => array('publish'), 'posts_per_page' => 5, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'related_club', // name of custom field 'value' => '"' . get_the_ID() . '"', // matches exactly "123", not just 123. This prevents a match for "1234" 'compare' => 'LIKE' ), array( 'key' => 'related_club', 'compare' => '=', 'value' => '', ) ) ); $context['promotions'] = Timber::get_posts($promotions); $timetableArgs = array( 'post_type' => 'club', 'post_status' => array('publish'), 'posts_per_page' => 1, 'post_parent' => $clubID, 'name' => 'timetable' ); $the_query = new WP_Query( $timetableArgs ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $context['timetable_page'] = $post; } /* Restore original Post Data */ wp_reset_postdata(); } wp_reset_postdata(); $meta_query = array( array( 'key' => 'related_club', // name of custom field 'value' => '"' . $clubID . '"', // matches exactly "123", not just 123. This prevents a match for "1234" 'compare' => 'LIKE' ) ); // Business Partners Query // $busArgs = array( 'post_type' => 'business-partner', 'post_status' => array('publish'), 'posts_per_page' => 1, 'meta_query' => $meta_query ); $businessPartners = Timber::get_posts($busArgs); $context['business_partners'] = $businessPartners; }elseif($post->post_parent != 0){ $club = new TimberPost($post->post_parent); $template = 'single-club--subpage.twig'; } if ( post_password_required( $post->ID ) ) { Timber::render( 'single-password.twig', $context ); } else { Timber::render( array( 'single-' . $post->ID . '.twig', $template ), $context ); }