Custom post type archive templating

Using Sage 9, custom post type templating doesn’t appear to work with the normal WP convention.

e.g. archive-posttype.blade.php does not register over archive.blade.php.

Anyone got this working on Sage9?

Unable to reproduce

Yes

Thanks Ben!

I should also add, not only is the custom archive template not loading, but I am also getting this PHP warning visiting a CPT archive when only archive.blade.php exists:

Warning: reset() expects parameter 1 to be array, null given in /...../web/app/themes/kernl-wp/vendor/brain/hierarchy/src/Branch/BranchPostTypeArchive.php on line 53

Anyone else?

What modifications have you made to your site?

This does not happen on a default Sage install

Strange - not sure if this is it, but I register the CPT’s in a class. When I drop it in directly (like in setup.php) everything works as expected.

I believe I found the issue, it was in the way I used pre_get_posts to include CPT’s by default

2 Likes