Thanks for your reply!
The thing is the trait is working fine, because I can print my query in my Blade view just fine, but somehow the have_posts()
function doesn’t recognize it as a WP_Query.
When I directly use the Trait in my view like this:
use App\Controllers\Traits\News;
$newsItems = News::getNews(6);
And use the loop like this:
@if ($newsItems->have_posts())
@while ($newsItems->have_posts())
@php($newsItems->the_post())
@endwhile
@endif
The loop works fine?