I'm working on building a block theme with a custom post type that uses ACF custom fields. I'm trying to figure out the optimal way to build the template for the single view of the custom post type (CPT).
I've tried creating a single-{custom post type}.html file and adding it in the templates folder. Still, because it is HTML, I can't pull in ACF fields there, so next, I thought I could build a block pattern since those are built using PHP and added it to the patterns directory and then just call the pattern from the template file. However it seems that the pattern file can't access things like get_the_ID() so I can't grab the ACF field data from within the pattern file either.
What I ended up settling on was creating a custom block that built out the layout for the CPT's single view and then just added the custom block call directly into the template file.
This feels like a bit of a round about way to get his done and I'm not sure if there is more optimal approach that doesn't require building a whole custom block piece and instead just directly builds the layout more directly.
EDIT: I worked out some boilerplate for putting a single-{custom post type}.php in the theme's root that would load the template parts properly for the header and footer I'll include below for others. I'm sure it could be refined further by someone more skilled than I but it should serve as a decent starting point.
I still wish there was a way to get custom PHP more directly into template files / block patterns so files would remain logically clustered together within the file structure of the theme.
```
<?php
/*
Template Name: Single Book
*/
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<?php
// We have to pull the template parts above the wp_head() call to ensure all the CSS comes along.
// Simply using block_header_area() or block_footer_area() was causing an issue with some missing CSS resulting in layout changes.
$page_header_content = do_blocks( '<!-- wp:template-part {"slug":"header","tagName":"header","className":"site-header"} /-->' );
$page_footer_content = do_blocks( '<!-- wp:template-part {"slug":"footer","tagName":"footer","className":"site-footer"} /-->' );
?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<!-- Site Header as defined in template parts -->
<?php echo $page_header_content; ?>
<article class="wp-block-group is-layout-flow wp-block-group-is-layout-flow">
<div class="entry-content wp-block-post-content has-global-padding is-layout-constrained wp-block-post-content-is-layout-constrained">
<!-- Custom content for the CPT layout goes here -->
<p>Custom Content</p>
</div>
</article>
<!-- Site Footer as defined in template parts -->
<?php echo $page_footer_content; ?>
<?php wp_footer(); ?>
</body>
</html>
```

It’s not a html, it should be single-{custom post type}.php