Have you read the error? The first line tells you exactly what’s wrong.
I’m sure I’m missing something and not understanding what the error is. I was able to use your previous last solution, and get it to render, but unclear on getting to just show that category correctly in an archive view. I am getting duplicates or anything other than expected results.
I updated, but other categories continue display.
public function with()
{
return [
'getPosts' => function ($post_type, $num, $category) {
return new \WP_Query([
'post_type' => $post_type,
'posts_per_page' => $num,
'category_name' => $category,
]);
}
];
}
Thank you.
You’re not providing enough context and code here for us to effectively debug your issue.
- The error you posted says you’re trying to echo a WP_Query object, which you can’t do. You need to modify your code to loop over the query results.
- I don’t understand what you’re asking with your most recent post: you’ve only posted a small snippet of code, but no indication of how it’s used.