Skip to content

Instantly share code, notes, and snippets.

@alexmustin
Created July 9, 2023 20:09
Show Gist options
  • Save alexmustin/621a7770209d01605bdc2bf1775e6a09 to your computer and use it in GitHub Desktop.
Save alexmustin/621a7770209d01605bdc2bf1775e6a09 to your computer and use it in GitHub Desktop.
ACF Blocks - custom SVG icon
<?php
// Example: icon with SVG code.
acf_register_block_type( array(
'name' => 'image-with-text',
'title' => __('Image with Text'),
'description' => __('A custom block for Image with Text.'),
'render_template' => 'template-parts/blocks/image-with-text.php',
'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0V0z" /><path d="M19 13H5v-2h14v2z" /></svg>',
'category' => 'ap-blocks',
'keywords' => array( 'text, image, image with' ),
));
// Example: icon from SVG file.
acf_register_block_type( array(
'name' => 'image-with-text',
'title' => __('Image with Text'),
'description' => __('A custom block for Image with Text.'),
'render_template' => 'template-parts/blocks/image-with-text.php',
'icon' => file_get_contents( get_template_directory() . '/images/svgs/image-with-text.svg' ),
'category' => 'ap-blocks',
'keywords' => array( 'text, image, image with' ),
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment