Support Forum
Support › Meta Box Builder › Icon field not loading icons in post edit page
Hello,
I have an issue with the icon field, using custom SVG icons.
I tried both methods described here: https://docs.metabox.io/fields/icon/#using-svgs
1. Adding the dir to the svg files directory (tried relative/absolute path)
2. Adding the svg code directly in a json file
In both cases the icons wont load in the post edit screen
(link to screenshot: https://drive.google.com/file/d/1m0Mk_aDdL3SehnHYbAyXJnZgy2tDCDwa/view?usp=sharing)
If I use the free Awesome Fonts the field works fine.
Can you help?
Kind regards
Hello Elene,
What is the absolute path you add to the icon dir setting? Simply, you can echo the WordPress function get_stylesheet_directory()
to get the path to the current theme folder.
I tried all the following paths without success:
- https://example.com/wp-content/themes/mytheme/assets/svg/
- /wp-content/themes/mytheme/assets/svg/
- wp-content/themes/mytheme/assets/svg/
get_stylesheet_directory() retrieves the absolute path on the server, so I tried also the following paths, without success:
- /home/user/public_html/wp-content/themes/mytheme/assets/svg/
- home/user/public_html/wp-content/themes/mytheme/assets/svg/
Kind regards
Hello,
Please share your site credentials via this contact form https://metabox.io/contact/
I will take a look.
I sent them to you, thanks.
The new icon field is added here with name "New Icon field": https://pbservices.ge/wp-admin/post.php?post=16182&action=edit
And it is visible in this post type under the tab "Features Bottom": https://pbservices.ge/wp-admin/post.php?post=19547&action=edit
Hello,
The correct path is
/home2/pbfinanc/public_html/wp-content/themes/generatepress_child/assets/svg/
I add it to the option icon_dir and the icons show as well, screenshot https://imgur.com/9i1OyaD
Thank you!
I suggest you to update the docs/screenshot in the section https://docs.metabox.io/fields/icon/#using-svgs, as it may be misleading for other users.
Kind regards
Sorry,
I have a second issue when I try to output the SVG icon.
With both these functions nothing is returned:
{{ mb.rwmb_meta( clone.feature_icon_2 ) }}
{{ mb.rwmb_the_value( clone.feature_icon_2 ) }}
If I output instead directly the icon value, it shows correctly the icon name:
{{ clone.feature_icon_2 }}
outputs:
bx-check-circle
Am I using the wrong syntax to show the custom SVG code?
Kind regards
Hello,
The data saved to the database is the icon name so you should wrap it in an HTML tag to output the file URL. For example:
{% for clone in post.group_field_id %}
{% set icon_name = clone.icon_field_id %}
<img src="{{ mb.get_stylesheet_directory_uri() }}/assets/svg/{{ icon_name }}.svg" />
{% endfor %}
Hello,
your solution was working good.
But with the latest plugin update (Metabox version 5.9.1) the icon edit field does not load the icons again.
The path that was currently working before the update was "/home*/***/***/wp-content/uploads/assets/svg/".
Can you help?
I can confirm that the icon field is no longer loading the assets as of 5.9.1 in both the builder and the front-end. In my case it is the default Font Awesome library. It is easy to duplicate the issue: simply add the icon field to your field group. Then in your custom post: attempt to select an icon but none appear.
I assume it is from the update to 5.9.1, but I am unable to verify as the plugin immediately updates upon restoring a backup.
Hello,
Please use the version 5.9.0 to show the icon field. The development team is checking the issue and I will let you know when I have any information.
Hi Peter. I was able to revert and can confirm 5.9.0 works as expected.
Previous versions can be downloaded at the WordPress Meta Box Plugin page → Advanced View → Previous Versions.
Or use wp-cli like I did:
cd wp-content/plugins
wp plugin auto-updates disable meta*
wp plugin delete meta-box && wp plugin install meta-box --version=5.9.0 --activate
Hi,
I'm experiencing the same issue. How can I download the 5.9.0 version please? ]
Thanks,
Filippo