# Custom post type archive on a custom page template

**URL:** https://discourse.roots.io/t/custom-post-type-archive-on-a-custom-page-template/12980
**Category:** sage
**Tags:** webpack, sage9
**Created:** 2018-07-19T06:12:04Z
**Posts:** 10
**Showing post:** 2 of 10

## Post 2 by @craigpearson — 2018-07-19T08:02:12Z

This is seen as the “right” way to achieve what you describe: [https://codex.wordpress.org/Plugin\_API/Action\_Reference/pre\_get\_posts](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts)

The above would alter your main loop so that you don’t have to create a new WP\_Query in your template part. If you need more assistance with this hook then [stackexchange](http://wordpress.stackexchange.com/) covers a lot of similar questions

Alternatively you could leverage the Controller to make your data available in your template files, however the controller approach wouldn’t be as _efficient_ as the `pre_get_posts` approach. More chatter about Controller usage here:

- [Using helper functions inside of a Blade template](https://discourse.roots.io/t/using-helper-functions-inside-of-a-blade-template/11265/6)
- [ACF Pro Repeater Fields w/ Sage 9](https://discourse.roots.io/t/acf-pro-repeater-fields-w-sage-9/12901)
- [https://github.com/soberwp/controller](https://github.com/soberwp/controller)

---

_[View the full topic](https://discourse.roots.io/t/custom-post-type-archive-on-a-custom-page-template/12980)._
