Template for a CPT

[ad_1]

Hey everyone,

I’m hoping you can point me in the right direction on how to handle the following:

My site (personal project) has a lot of posts of a CPT that are structurally the same (i.e. same set of blocks in each post), with all non-static content needed by the blocks coming from various ACF fields. Thus, for each individual post of the CPT only the ACF fields are ever modified.

I currently have a design (collection of blocks) that I am happy with and which seem to work well. The data is drawn from the ACF fields as desired. The problem is that the set of blocks has to be manually put in each post, which is both inefficient and means that any changes to the design needs to be manually copy-pasted to every post. That won’t be workable as the site grows.

What I’d like to do is have the current design be linked to the CPT itself rather than to individual posts of that CPT. On the backend, I’d just have my ACF fields for quick, clean data entry (ideally not even seeing the set of blocks on the backend; just the ACF fields). On the front end, my collection of blocks would be rendered, drawing upon the ACF fields for the dynamic content.

I assume I need to create a post template for this (i.e. single-cpt.php, for example) but I am totally unclear on how I specify my blocks within that post template (if that is even the correct approach). Everything I am finding in my online searches is just telling me how to display `the_post` or `the_title` rather than how to display a set of specific blocks (with associated properties for each block) within `the_post`.

Any guidance on how to best approach this and where I can find detailed examples would be hugely appreciated.

In case it matters, I am currently using the Blocksy theme though I can switch to another if needed. For blocks, I’m using a combination of native Gutenberg blocks as well as blocks from GreenShift (premium). I also have a ‘pro’ license for Stackable though I am not currently using it for this project. I have ACF Pro available.

I’m an experienced programmer but only have basic expertise at PHP and only a hazy understanding of the developer-related components of WordPress. Thus, seeing some examples or having some in-depth tutorials would be ideal, though I can probably figure things out on my own if someone can at least point me in the right direction.

Thanks in advance!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer