is_registered( $name ) ) { register_block_pattern_category( $name, array( 'label' => $name ) ); } } } $empty_template_array = []; foreach($templates_lists as $template){ $new_template_array = []; $new_template_array = array( 'title'=>$template['name'], 'categories'=>$template['item'], 'content'=>$template['content'] ); array_push($empty_template_array,$new_template_array); } // Register pattern if(!empty($empty_template_array)){ $i=0; foreach($empty_template_array as $new_template){ $i++; register_block_pattern( 'blockspare/blockspare-pattern-'.$i, $new_template ); } } } add_action('init','blockspare_register_block_pattern'); }