Icon field not loading icons in post edit page
Support › MB Builder › Icon field not loading icons in post edit page
- This topic has 20 replies, 6 voices, and was last updated 1 year, 2 months ago by
Bomes.
-
AuthorPosts
-
December 5, 2023 at 3:01 PM #44016
Elene Gabelaia
ParticipantHello,
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 fileIn 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
December 6, 2023 at 8:46 PM #44024Peter
ModeratorHello 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.December 7, 2023 at 6:47 PM #44034Elene Gabelaia
ParticipantI 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
December 7, 2023 at 10:57 PM #44042Peter
ModeratorHello,
Please share your site credentials via this contact form https://metabox.io/contact/
I will take a look.December 8, 2023 at 4:17 PM #44043Elene Gabelaia
ParticipantI sent them to you, thanks.
December 8, 2023 at 4:22 PM #44044Elene Gabelaia
ParticipantThe 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=editDecember 8, 2023 at 8:51 PM #44045Peter
ModeratorHello,
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
December 8, 2023 at 10:56 PM #44046Elene Gabelaia
ParticipantThank 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
December 9, 2023 at 4:07 PM #44048Elene Gabelaia
ParticipantSorry,
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
December 10, 2023 at 10:58 AM #44051Peter
ModeratorHello,
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 %}
December 27, 2023 at 3:54 AM #44172Elene Gabelaia
ParticipantHello,
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?
December 28, 2023 at 3:24 AM #44177Log
ParticipantI 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.
December 29, 2023 at 4:45 PM #44183Peter
ModeratorHello,
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.
December 30, 2023 at 1:08 AM #44188Log
ParticipantHi 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
December 30, 2023 at 1:32 AM #44189Filippo Ponzetti
ParticipantHi,
I'm experiencing the same issue. How can I download the 5.9.0 version please? ]
Thanks,
Filippo -
AuthorPosts
- You must be logged in to reply to this topic.