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.
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?
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!