I’m having issues with @posts directives and $posts variable in a view.
Here is a working example of my single-collection.blade.php
There is a @posts on which I run another @query with @posts and @endposts.
Then I output the main @posts @content (my collection post type).
Then starts the issues.
If I use another @query (even without adding @posts or @hasposts) the script goes infinite loop.
That’s why for the last subquery I’m using plain WP_Query and @while directives.
But if I change $pages
variable name with $posts
then the view goes again in infinite loop.
This let me think there is an issue with the $posts variable itself.
Can you help me also with that?
@posts
@query([
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
])
@posts @include('partials.content-gallery') @endposts
@content()
@php
$pages = new \WP_Query([
'post_type' => 'collection',
'post_parent' => $post->ID,
'orderby' => 'menu_order',
'posts_per_page' => -1
]);
@endphp
@while($pages->have_posts()) @php $pages->the_post() @endphp
@include('partials.content-collection')
@endwhile
@php wp_reset_postdata() @endphp
@endposts