0

I would like some advice on how to set up a job. I have a set of "content blocks" I give an example:

Block 1 | Block 2 | Block 3 | Block 4 | Block 5

The goal is to make in a fairly fast way a page that contains only a few blocks ex Block 1 | Block 3 | Block 5

Basically, I haven't tried anything yet. What I thought is to create a custom post with some metadata that will serve as a filter and another custom post with blocks. I stopped on linking the two custom posts to generate this page. The person who will do this will not be very familiar with Wordpress. I was assigned to create the structure.

I greatly appreciate any suggestions and thank you in advance

2
  • 1
    What have you tried? What specific problem are you having? Please edit your question to provide us more detail on this.
    – Pat J
    Dec 1, 2023 at 14:10
  • I read your question several times but couldn't figure out what you were asking, there are a lot of things mentioned but they aren't connected to eachother clearly, so it's not clear what you're trying to do or what the question is. Remember this isn't a discussion forum it's a Q&A site, you need a specific question that an answer can be written for, that you can mark as correct. Opinions/discussions/chat are better had on other sites
    – Tom J Nowell
    Dec 1, 2023 at 16:07

1 Answer 1

0

I'm not 100% sure I understand. Are you asking how you can determine ahead of time what blocks will be available to a template? That's what this answer will be for.

Option 1: Patterns

Wordpress 6.4 has the ability for you to make patterns from the admin. To do this, open a page or post and add the blocks you want to be available. Then you can select them all and "create pattern" from their toolbar. Name it, and create a category for it. Then you can go into any post or page (custom post types included) and you should be able to find that pattern during block selection to apply to the page. Given instructions, anyone doing content entry can do this.

Option 2: Define the template starting blocks.

If you're looking for a more automatic solution, this is it.

Apply this code (in your functions.php most likely). This allows you to choose a post type (here it's 'post') and then you can choose blocks to add. In this one, there's a pattern (this is just an example to show that you can do this with patterns as well as blocks), followed by a heading, and then a paragraph block.

function register_default_posttype_patterns() {
   // set default page layouts
   $selected_post = get_post_type_object( 'post' );
   $selected_post->template = array(
       array( 'core/pattern', array( // pattern format
           'slug' => 'text-domain/patterns-slug',
       ) ),
       array( 'core/heading' ), // block format
       array( 'core/paragraph' ) // block format
   );
}
add_action( 'init', 'register_default_posttype_patterns', 11 );

For your purposes, you might remove the array with the pattern, and then update it for Block 1, Block 3, Block 5 as you said. Then anytime someone opens up a "Post", it will start with those three blocks already applied.

I hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.