Hello there. I’m having trouble adding a custom icon to my ACF Gutenberg block. I’m using ACF 5.8.0-beta2 and WordPress 4.9.8.
My code is below though the icon code is taken directly from the acf_register_block() documentation. The block itself works great but all I get is a blank icon.
When I look at the source code there is nothing to display. It’s almost like WP has scrubbed it out. There is also no errors in the console.
acf_register_block(array( 'name' => 'campactivities', 'title' => __('Camp Activities Grid'), 'description' => __('A custom grid to display camp activities.'), 'render_template' => 'template-parts/block/content-camp-activities.php', 'category' => 'common', '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>', 'post_types' => array( 'page' ), 'align' => false, 'keywords' => array( 'daily', 'activities', 'grid' ), ));
Thanks for any help you can give.
Same here. Can’t get anything to display but a dash-icon.
I am dealing with this glitch as well. It does not work when setting icon or declaring the array with src
Same here. Any word if a fix for this is rolling out in the next release? Would be great to not be limited to Dashicons.
It looks like this issue is marked as “Solving”, so hopefully a permanent fix is on the way soon. However, I was having the same issue, so I created my own fix for the time being. It’s a drop-in plugin, just download and activate and it should work for you. Everyone is welcome to check it out to see if it fits your needs: https://github.com/pfaciana/acf-block-icon
@philf Your plugin works like a charm! Thank you for taking the time to make it.
No problem! Happy I could help. I needed it for myself anyway, no reason not to open source it and let others use it. Thanks!
An update for anyone coming here now… For me I had no issues adding an SVG icon as per the ACF docs (no plugin needed). Now if you are adding an icon for a custom category, that’s a whole other thing and not as easy. But for a just a custom ACF block, I could drop in the SVG code no issues.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.