I am using the Social Icons Widget within Elementor. The urls come from Advanced Custom Fields (ACF) attached the the post.
If one of the urls is empty though, I do not want the icon to show.
I have been trying use the hook ‘elementor/widget/render_content’ but not sure what do do with it once I have the element.
2
Answers
A bit late but for others that wants a solution for this. You may use Elementor’s Custom Code and insert a javascript code that will remove the empty links once the page has loaded.
This code checks for all the social icons with a class of
elementor-social-icon
then removes the span container that contains the anchor tag if thehref
attribute is undefined or blankThe JavaScript solution above is great, but I would instead opt for a custom style, since
:not()
is broadly supported nowadays. If you are in need of a pure CSS solution, I would use the following: