-
Anonymous
Hello,
I’m trying to make every menu item have a dynamic icon and looks like it is not there yet.
There’s no tag inserter and I’ve tried to use an ACF/SCF Icon picker and text field, but I cannot get the right output.Is it even possible? 🙂
-
Hi there,
I don’t think it will work with the icon picker field.
However, you should be able to pull the SVG as image, or use the WYSIWYG field to add media, then use text/headline block to pull its content.
-
Anonymous
I’ve tried and it does not work. For an icon to work, it has to be an SVG code, right?
Neither the image nor the WYSIWYG field outputs SVG code.
-
No, direct SVG code won’t work, the ACF field won’t take it for security reasons.
You need to upload the SVG as image, and pull it as an image.
-
Anonymous
Yes, but the image field outputs an array, URL, or ID and doesn’t make an image, so I get a URL/ID string instead of an icon.
And WYSIWYG adds p tags and breaks the markup. It’s also bad UI/UX to add an image like that 🙂 -
Set the return value of the image field to URL, you can use GB image block to pull post meta > image field slug.
-
Anonymous
But I don’t want an image block, I want a text block inside a query loop to have a dynamic icon.
Here’s an example:
{{post_meta key:icon|required:false}} {{post_title}} -
It’s not possible, WP does not allow SVG HTML to be stored in custom fields.
-
Anonymous
Not sure if that’s the case.
I can store it via ACF text or textarea field and echo it with
<?php echo get_field('icon'); ?>
, maybe there’s a workaround to bypass wp_kses_post inside the “Custom SVG” field? -
Hi there,
its not possible currently.
There are some things we have to jump over in order to make that work. I’ll raise it as a feature request for further investigation. -
Anonymous
Great, thanks.
-
You’re welcome
- You must be logged in to reply to this topic.