I have added some settings for authors to add social media links which will appear on the author.php page.
any suggestions to your question will possibly depend on what code you are using for that.
please post your code.
This forum “How-To and Troubleshooting” is for standard WordPress use, not software coding.
But to answer your question, doesn’t this involve checking to see if the fetched database data field is empty? If it is, then don’t generate the HTML for the section. And if you choose to generate it, then simply hide it with CSS.
Hi Michael,
This is my functions.php code:
// ADDITIONAL AUTHOR PROFILE SETTINGS
function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';
// Add Instagram
$contactmethods['instagram'] = 'Instagram';
// Add Pinterest
$contactmethods['pinterest'] = 'Pinterest';
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
and this is what I have in my author.php page:
<h2>Social homes</h2>
<p>
<a href="<?php echo $curauth->twitter; ?>">Twitter</a><br>
<a href="<?php echo $curauth->facebook; ?>">Facebook</a><br>
<a href="<?php echo $curauth->instagram; ?>">Instagram</a><br>
<a href="<?php echo $curauth->pinterest; ?>">Pinterest</a>
</p>
you could for example try:
<?php if( isset( $curauth->facebook ) ) { ?>
<a href="<?php echo $curauth->facebook; ?>">Facebook</a><br>
<?php } ?>
etc
Thanks for that Michael.
It still brought up the facebook link though, even though it wasn’t entered in the settings. It just links to the author page…?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
If the Facebook link isn’t entered into the settings, what does this output:
$curauth->facebook
??