Support

Account

Home Forums ACF PRO Linking social media icons to blog author page

Solved

Linking social media icons to blog author page

  • 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;
    }

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.