I have a query using the paostnamein for my query. Each section of the page uses a different partial, but repeats the first posts content.
My code.
class FrontPage extends Controller
{
public function featuredSections(): \WP_Query
{
$args = [
‘post_type’ => ‘page’,
‘post_name__in’ => [‘hero’, ‘about’, ‘classes’, ‘instructors’],
‘posts_per_page’ => 1,
‘post_status’ => ‘published’,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’,
‘nopaging’ => false,
‘no_found_rows’ => true
];
return new \WP_Query($args);
}
}
My blade tempate:
@extends(‘layouts.home’)
@section(‘home’)
@if($featured_sections->have_posts())
@while($featured_sections->have_posts()) @php $featured_sections->the_post() @endphp
@php $count = 0 ;$count++; @endphp
@include('front-page.hero')
@if ($count === 1)
@include('front-page.about')
@endif
@if ($count > 1)
@include('front-page.classes')
@endif
@if ($count > 2)
@include('front-page.instructors')
@endif
@endwhile
@endif
@endsection