Hello .I have problem with posts_per_page option, i cant show how many post i want in my custom template, its just show all the post. Here is my code
@php
$args = [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => '2',
];
$the_query = new WP_Query( $args );
@endphp
@if ( $the_query->have_posts() )
@while ( $the_query->have_posts() ) @php $the_query->the_post() @endphp
@php $featured_image = get_the_post_thumbnail(get_the_id(), 'medium') @endphp
<article>
<div class="img-post">
@if(has_post_thumbnail())
{!! $featured_image !!}
@endif()
</div>
<h3>{{ get_the_title() }} </h3>
</article>
@endwhile<!-- end of the loop -->
@endif
@php wp_reset_postdata() @endphp