Custom post type archive on a custom page template

@trainoasis @craigpearson

What’s your custom template for? If its primary purpose is to display a list of your custom posts, the best approach may be to just add an archive-myposttype.blade.php template for this and let WordPress do the querying, etc., for you.

Otherwise, I would almost certainly go the controller route; I don’t think pre_get_posts would be a good option here. If you’re making an independent page, so to speak, and not just a customized archive for the CPT, the page will have its own data that the query fetches. If you use pre_get_posts to hijack the query that is happening when your page is loaded to get your list of posts, it will no longer contain your page’s data. Instead, leave the page’s query alone and use the controller to fetch the posts you need and pass them to your template.