james-dg
Member
Posted 5 months ago #
Sounds like a pretty weird thing to ask but here is what I'm looking for...
I have some custom fields on the user area in wordpress. These are then shown on the author page.
What I have right now is users enter their facebook link and it will add a facebook icon to the page. The only problem is if a user doesn't enter their url there is just a facebook icon there with no link.
Is there a way to only show the image if a url has been added?
Thanks :)
How are you calling the link & icon?
james-dg
Member
Posted 5 months ago #
<a href="
<?php $user = $curauth;
// is there someone logged?
if ($user->ID) {
$value = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'FACEBOOKURL'));
echo $value;
}?>">
<img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="find us on facebook"/></a>
Not sure If i'm even doing it right :')
Try:
<?php if( $value && $value !='' ):?> <img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="find us on facebook"/></a><?php endif;?>
james-dg
Member
Posted 5 months ago #
Thank you Esmi :)
I had to alter it slightly because it wouldn't show the closing tag on the link.
<a target="_blank" href="http://www.facebook.com/<?php $user = $curauth;
if ($user->ID) {
$value = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'FACEBOOKURL'));
}?>
<?php echo $value ?>">
<?php if( $value && $value !='' ):?><img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="Find us on facebook"/><?php endif;?>
See it in action :)