How to makes Custom Post Type posts as Gutenberg’s patterns?

Use a single init action’s callback, with the whole loop in there, to make sure the scope and execution order is correct.