Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

[GB2.0a1] Dynamic tags and SVG icons

  • 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.

  • 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.

  • 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.

  • 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:
    SVG
    {{post_meta key:icon|required:false}} {{post_title}}

  • It’s not possible, WP does not allow SVG HTML to be stored in custom fields.

  • 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.

  • Great, thanks.

  • You’re welcome

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.