Hi, i’ve created social media fields for my blog authors so that they can show as icons on their author pages. I can get the images to show on the page and the links do get pulled to the page from the user profile – i did that by using DIVI dynamic content on the links. That works fine. However, if the user does not include a social link on their profile (eg they have Facebook and Insta but not Twitter), the Twitter icon still shows on the author page and i can’t find a way to hide it.
I started out with the icons and it didn’t work so then thought to try with code and then add the icons in later using CSS. I tried using this (taken from the ACF get values from a user page) and modified it but i don’t think i got it right. And i’m not sure if i’m even putting it in the right place or if i need to add anything to function.php page (complete techy newbie here!)
<?php
$author_id = get_the_author_meta('ID');
$dt_facebook_url = get_field('dt_facebook_url', 'user_'. $author_id );
?>
<p>
<a href="<?php echo $dt_facebook_url['url']; ?>" alt="facebook>" />Test</a></p>
Ideally i’d prefer to go with the first option (as the icons are already working mostly) but if anyone has any suggestions, i’d appreciate it. Images attached showing the fields etc.
Thanks,
Nic
For anyone interested, i managed an easy css fix that required none of the above.
this to the style sheet:
.et_pb_social_media_follow .icon[href=””] {
display: none;
}
Hi dpeople!
I am trying to achieving the exact same thing. I have created the ACF fields for the users.
I have tried your CSS code but it does not work for me. It stills showing social icons even if there is no URL.
Is there anything more I could do?
thanks!
Sorry #iciaretxebarria, Iām on holiday atm and have no computer to look. Good luck with it!
Hi dpeople!
Enjoy your holidays!
I have just found how to make it work for me š If anyone needs it. Just add an “#” in the attribute selector š
.et_pb_social_media_follow .icon[href=”#”]{
display: none;
}
Have a nice day!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.