Home › Forums › Backend Issues (wp-admin) › font awesome with the render field
How can I use the repeater, Url field and font awesome to render any icon from the font awesome list when I add their social media link.
Here a could from an old project that I did last year. Right, the that him going to show you that every time someone has to add new social media font awesome code intro code file.
I want the user to automatically when every they added their social link it just adds the icon without going into the code.
<?php if( have_rows('setting_api_header', 'option') ): ?>
<div class="social-media" id="scroll-btn">
<?php while( have_rows('setting_api_header', 'option') ): the_row(); ?>
<?php $twitter_url = get_sub_field('twitter' , 'option');
if( $twitter_url ):
echo '<a target="_blank" href="'.$twitter_url.'"><i class="fa fa-twitter"></i></a>';
endif;
?>
<?php $linkedin_url = get_sub_field('linkedin' , 'option');
if( $linkedin_url ):
echo '<a target="_blank" href="'.$linkedin_url.'"><i class="fa fa-linkedin"></i></a>';
endif;
?>
<?php $youtube_url = get_sub_field('youtube' , 'option');
if( $youtube_url ):
echo '<a target="_blank" href="'.$youtube_url.'"><i class="fa fa-youtube"></i></a>';
endif;
?>
<?php $instagram_url = get_sub_field('instagram' , 'option');
if( $instagram_url ):
echo '<a target="_blank" href="'.$instagram_url.'"><i class="fa fa-instagram"></i></a>';
endif;
?>
<?php $twitch_url = get_sub_field('twitch' , 'option');
if( $twitch_url ):
echo '<a target="_blank" href="'.$twitch_url.'"><i class="fa fa-twitch"></i></a>';
endif;
?>
<?php endwhile; ?>
</div>
<?php endif; ?>
Since you have a different sub field for each social site, then you can’t. You’ve basically got to create a new field for every one and then add the code.
You should use a repeater field, let them add the name of the site like “YouTube” let them add the link and then let them add the icon they want to use with something like this https://wordpress.org/plugins/advanced-custom-fields-font-awesome/.
The topic ‘font awesome with the render field’ is closed to new replies.
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.