First of all, excuse me for my lack of knowledge, i’m a french student and it’s my first experience with wordpress and ACF Pro.
I’ll try to be as clear as possible. Thanks to my school, I can work in an enterprise every weeks. In this agency, I have to work on a WordPress website with ACF Pro. The goal is to make the website easy to manage for them. We are using the Astra Pro theme.
I managed to create Custom Post Type, ACF Blocks and so on but I’m stuck about how to display them. I created multiple ACF Blocks thanks to the acf_register_block_type() function and every block has his own render_template/style inside a specific folder.
I have a specific Custom Post Type which need to be always the same, so a template.
I already use the “template” option inside arguments when I register the CPT with register_post_type( ‘my-cpt’, $args ) and it’s working as intended, when I create a new “my-cpt” post, I do have my blocks and we can manage them, delete some, add some…
My problem is, I have an header block with some informations that must do the full width of the page, and some others should be inside a wrap (like my first attachment).
The way I made my blocks, they all have their own php file and css file and I have no way to add a wrap “around” the blocks I want to be in the wrap (I tried the wp:group thing but couldn’t find a way to add this to the template args when I register the CPT).
The way my CPT is actually display is using a “single-mycpt.php” file. Inside it, I’m using the “astra_content_loop” function of Astra, which is the equivalent of “the_content” function of wp I believe. This way, I have no way of adding my wrap around specific blocks.
The workaround i’m using right now is by actually give a “fullpage” class to the elements I want to be 100%, and others have by default 70%.
My question may be around CSS but I really would like to know whats the best practice on “how to manage templates with ACF Blocks on specific custom type” (aka, should I have each block with his own php/css file then add them in the “template” arg when I register the CPT or is there any better way ?)
Sorry again if my english is bad, i’m really desesperate on how to do this and can’t find any real solutions when looking for my problem.
Thanks a lot for your answers
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!