Last active
February 16, 2022 20:31
-
-
Save khleomix/9615cd65cbe6bc26c94cede2d3d9582d to your computer and use it in GitHub Desktop.
ACF Custom Block Category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a Custom Block category to the Gutenberg category list. | |
* Use in acf_register_block_type ( [ 'category' => 'custom-blocks' ] ). | |
* | |
* @param array $categories The existing categories. | |
* @param object $post The current post. | |
* @return array The updated array of categories. | |
* @author JC Palmes | |
*/ | |
function acf_blocks_add_block_categories( $categories, $post ) { | |
return array_merge( | |
$categories, | |
array( | |
array( | |
'slug' => 'custom-blocks', | |
'title' => esc_html__( 'Custom Blocks', 'theme' ), | |
), | |
) | |
); | |
} | |
add_filter( 'block_categories_all', 'acf_blocks_add_block_categories', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment