Last active
September 4, 2023 15:19
-
-
Save johnmccole/bc292157185c18376121de9d953c9bb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
// Get current post ID. | |
$id = get_the_ID(); | |
// Get Relationship from post using it's ID | |
$posts = get_field('posts', $id); | |
$post_ids = array(); | |
$post_types = array(); | |
if($posts) { | |
foreach($posts as $post) { | |
$post_ids[] = $post->ID; | |
$post_types[] = $post->post_type; | |
} | |
$args = array( | |
'post_type' => $post_types, | |
'post__in' => $post_ids, | |
); | |
} | |
// New query using the arguments. | |
$post_query = new \WP_Query($args); | |
@endphp | |
@php // Check query has posts. @endphp | |
@if($post_query->have_posts()) | |
<div class="case-studies alignfull d-flex align-items-center has-blue-background-color vh-75"> | |
<div class="container-fluid d-flex h-100 align-items-center"> | |
<div class="row w-100"> | |
<div class="col-12 col-lg-10 offset-lg-1"> | |
<h2 class="text-uppercase has-white-color fw-light mb-4 mt-5">Related Case Studies</h2> | |
@php $i = 0; @endphp | |
@while ($post_query->have_posts()) @php $post_query->the_post() @endphp | |
@php $i++ @endphp | |
@endwhile | |
@php $c = 1; @endphp | |
<div class="post-slider"> | |
@while ($post_query->have_posts()) @php $post_query->the_post() @endphp | |
@include('partials.content-'.get_post_type()) | |
@php $c++; @endphp | |
@endwhile | |
</div> | |
<div class="arrows @if($c > 2) d-block d-lg-none @endif"></div> | |
<small class="d-inline-block mt-3 mb-4 has-white-color">{!! $i !!} Case Studies</small> | |
</div> | |
</div> | |
</div> | |
</div> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment