Home › Forums › General Issues › URL => Image
Hey all,
In my footer i want to have social icons.
These social icon links are going to be filled in on the back end of wordpress.
this works great, but when i call on the_field(‘facebook’, ‘option’); the url displays on the front-end (www.facebook.com) but i would like to change that to an facebook icon. so when you click on the icon, you will go to facebook.com
is this possible?
That’s not really something that ACF will do for you.
You have a few choices.
You can use CSS to replace the text in the link with the icon image you want to use. This will probably require altering the HTML and maybe how the field is output.
You can use an icon set that has the icons you want, for example http://genericons.com/. This is a font icon set used in several of the more recent default WP themes (2013, 2014, 2015) and you can see examples of how to use them by taking a look into those themes. Again, will require CSS work and maybe some HTML changes.
You can supply another field that allows you to upload an image file to use for the icon and use that along with the url to construct a the link. This will also need some changes to the HTML and CSS.
Awesome , that worked!
no i have the next problem
it is no link.
i have tried :
<div class="facebook-test">
<?php if(!empty(the_field('facebook' , 'option')) ) { ?>
<a href="<?php the_field('facebook' , 'option'); ?>" target="_blank"> </a>
<?php } ?>
</div>
and :
<?php if( get_field('facebook' , 'option') ): ?>
My field value: <a href="<?php the_field('facebook' , 'option'); ?>"> </a>
<?php endif; ?>
<br />
hoe can i make this image a link ? (the image or the tekst is no link) in the back-end i selected URL
Are you using the last one I mentioned? Using an image field?
would this work? :
<?php $facebook_url = get_field('facebook' , 'option');
if( $facebook_url ):
echo '<a target="_blank" class="facebook_icon" href="'.$facebook_url.'"><img src="https://www.facebookbrand.com/img/assets/asset.f.logo.lg.png" alt="facebook-icon"></a>';
//change src of facebook to your server
endif; ?>
Yes! awesome mediawerk Thank you very much
John also a big thanks! you guys helped me out a lot!
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!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.