Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Author social media aren’t shown on the page

Try This for IF :

if(!empty($user->user_url)) { 
   // OUTPUT
}

All Code


$website = $user->user_url;
if(!empty($user->user_url)) { 
   printf('<a href="https://wordpress.stackexchange.com/questions/353378/%s">%s</a>', $user->user_url, '<i class="icon-home"></i>'); 
}
$twitter = get_user_meta($user->ID, 'twitter_profile', true);
if(!empty($twitter)) {  
   printf('<a href="https://wordpress.stackexchange.com/questions/353378/%s">%s</a>', $twitter, '<i class="icon-twitter"></i>'); 
}
$facebook = get_user_meta($user->ID, 'facebook_profile', true);
if(!empty($facebook)) { 
   printf('<a href="https://wordpress.stackexchange.com/questions/353378/%s">%s</a>', $facebook, '<i class="icon-facebook"></i>');
}
$google = get_user_meta($user->ID, 'google_profile', true);
if(!empty($google)){
   printf('<a href="https://wordpress.stackexchange.com/questions/353378/%s">%s</a>', $google, '<i class="icon-google"></i>');
}
$linkedin = get_user_meta($user->ID, 'linkedin_profile', true);
if(!empty($linkedin)){ 
   printf('<a href="https://wordpress.stackexchange.com/questions/353378/%s">%s</a>', $linkedin, '<i class="icon-linkedin"></i>');
}

EDIT

Previously, you had to add code in the function according to your needs.

Example

<?php
//CREATE  CUSTOM USER DATA
add_action( 'show_user_profile', 'facebook_custom_extra_profile_fields' );
add_action( 'edit_user_profile', 'facebook_custom_extra_profile_fields' );

function facebook_custom_extra_profile_fields( $user ) { ?>

    <h3><?php echo esc_html__('Facebook URL','text-domain');?></h3>

    <table class="form-table">

        <tr>
            <th><label for="twitter"><?php echo esc_html__('Facebook URL','text-domain');?></label></th>

            <td>
                <input type="text" name="facebook_profile" id="facebook_profile" value="<?php echo esc_attr( get_the_author_meta( 'facebook_profile', $user->ID ) ); ?>" class="regular-text" /><br />
                <span class="description"><?php echo esc_html__('Please enter Facebook URL.','text-domain');?></span>
            </td>
        </tr>

    </table>
<?php }


//SAVE CUSTOM USER DATA

add_action( 'personal_options_update', 'facebook_custom_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'facebook_custom_save_extra_profile_fields' );

function facebook_custom_save_extra_profile_fields( $user_id ) {

    if ( !current_user_can( 'edit_user', $user_id ) )
        return false;

    update_user_meta( $user_id, 'facebook_profile', $_POST['facebook_profile'] );
}

?>

Related Posts:

  1. Use author author display name in permalink structure for pages and posts
  2. Possible to search by author name with default WordPress search function?
  3. Add admin bar link to edit author
  4. List repeating share links
  5. Authors details such as social media links, emails etc → Is this Meta or something else?
  6. Display the number of user comments
  7. How can I list random authors from current post category?
  8. Hide Author.php template from specific user role
  9. Only display link to author social media when it exists [closed]
  10. How to automatically remove links from WordPress Biographical Info?
  11. what function can I use to automatically output og tags per page/post?
  12. Commenter should see only his comments in wordpress
  13. Allow Post Author to be 0 on Update
  14. wp-comment author- url +, email filter hook
  15. check if author has published posts in custom post type, then send mail
  16. Skeleton Child Theme Add Icon Bar to Header Flex Grid
  17. Author Date Function not working as expected [duplicate]
  18. Filter to wp_list_authors
  19. Disabling Author Page only for subscribers
  20. If no author posts, echo out some text
  21. How can i list random author?
  22. Probleme shortcode with list author
  23. Get post_author email for Zapier Integration
  24. Why is wp_list_authors not picking up Authors from CPT’s?
  25. How To Display Author Popup on Entry Meta (Genesis Framework)?
  26. Author Page User id in functions.php for non login user
  27. Author info does not show up when author has no posts
  28. Show the online status of the current post’s author
  29. How to Insert A List of Posts in A Category Written by the Author into the Author Archive
  30. How to add user_registered time in human_time_diff() wordpress
  31. Include posts under a custom taxonomy in author.php
  32. Missing feature image link function
  33. What’s the difference between home_url() and site_url()
  34. Remove “Category:”, “Tag:”, “Author:” from the_archive_title
  35. get_template_directory_uri pointing to parent theme not child theme
  36. How to customize the_archive_title()?
  37. remove empty paragraphs from the_content?
  38. What is the “with_front” rewrite key?
  39. Why use if function_exists?
  40. How to override parent functions in child themes?
  41. wp_enqueue_script was called incorrectly
  42. Add multiple custom fields to the general settings page
  43. Ajax call always returns 0
  44. 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
  45. How long does a deprecated function live in core?
  46. Solution to render Shortcodes in Admin Editor
  47. How to add a data attribute to a WordPress menu item
  48. What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
  49. remove_action on after_setup_theme not working from child theme
  50. plugins_url vs plugin_dir_url
  51. Remove type attribute from script and style tags added by WordPress
  52. How to run a function every 5 minutes?
  53. Best way of passing PHP variable between partials?
  54. Upload Multiple Files With media_handle_upload
  55. How to display custom field in woocommerce orders in admin panel?
  56. Adding fields to the “Add New User” screen in the dashboard
  57. Issues with title-tag and document_title_parts
  58. How do I get the current edit page ID in the admin?
  59. How to check if a user exists by a given id
  60. Why isn’t is_page working when I put it in the functions.php file?
  61. Add tags to the section via functions.php
  62. Add image size if page template
  63. How to create a custom order status in woocommerce!
  64. Remove Actions/Filters added via Anonymous Functions
  65. Adding a second email address to a completed order in WooCommerce [closed]
  66. How to load parent_theme functions.php before child_theme?
  67. How to load scripts/styles specific for a page
  68. Programatically add options to “add new” custom field dropdown
  69. Is there any global functions.php file which works for any theme?
  70. Excluding iPad from wp_is_mobile
  71. When should you, and when should you not, use wp_list_pluck()?
  72. Get the ID of the page a menu item links to?
  73. Add container to nav_menu sub menu
  74. Difference between the_permalink() and get_permalink() function
  75. What’s the difference between WordPress random_int() and PHP built-in function random_int()?
  76. Child theme – Overriding ‘require_once’ in functions.php
  77. Link to user’s profile settings page?
  78. WordPress Enqueue for homepage only, functions.php, wp-framework
  79. get php variable from functions php and echo it in theme template files [closed]
  80. Get menu object from theme_location
  81. Is it ok to use a function to output the text domain name in a wordpress theme
  82. Displaying the number of updates available in the Admin area
  83. Trying to use add_action and do_action with parameters
  84. Use AJAX in shortcode
  85. Set JPEG compression for specific custom image sizes
  86. Can the new 4.8v text widget visual editor be removed?
  87. Prevent “main” WPMU site_url() being returned in functions
  88. Include files in child theme functions file
  89. Memorizing syntax
  90. Custom page with variables in url. Nice url with add_rewrite_rule
  91. Define page template in wp_insert_post
  92. Which WP functions do you need to use esc_html() or esc_url() on?
  93. Check if post is being published for the first time, or is an already published post being updated
  94. Display random categories on the front page (Finding and Editing Theme Functions)
  95. How to redirect to post if search results only returns one post
  96. remove links from images using functions.php
  97. Order posts (across the whole site) by metadata date
  98. Is it possible to rename a post format?
  99. Why does WordPress have private functions?
  100. Import WordPress XML File from Within Functions.php
Categories functions Tags author, functions, list-authors, social-sharing
Attend event form with ajax
WP_Query by MAX post_id?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress