ACF fields not working for Archive pages

Inside app/controllers/App.php, I added

protected $acf = true;

which allows

{{ $field_name }}

to be outputted for my page-name.blade.php templates.

But when I’m using archive-name.blade.php (with CPTUI archive on), the

{{ $field_name }}

no longer works.

It seems like for archive pages, the controller is acting differently. Any ideas?

I’m starting to think ACF can’t be used with archive, but only pages. ACF conditional only has option for pages. How can we add non-post ACF fields to an archive template?

I found this workaround, let me know if you can think of another way. So I want to display a page specific ACF field (non-post/non-loop) in an archive page. I first create the ACF field & show it on a page for edit, then inside the archive template, grab the page ID & then the ACF field that way.

But how can I add the field values to the page post type in the controller?

That will allow you to assign pages to custom post types, which will then act as archives for those types. It also exposes a function that you can use to get the ID of the page for that post type, which you can pass to ACF and get fields that way.


Related but not exactly what was asked for, I have some code I can dig up that makes a post type a “child” of a page, the way WooCommerce does with Products. If anyone’s interested.