/** * Retrieve user's custom social profile. * * @param int $id User ID. * @return array Custom user fields. */ function stag_get_user_social_profiles($id) { $fields = array(); $user_fields = stag_custom_user_fields(); foreach ($user_fields as $field_key => $field_value) { $fields[$field_key] = get_the_author_meta($field_key, $id); } return array_filter($fields); }
<?php if (!empty($authordata->description)) { ?> <div class="current-author__description"><?php echo wpautop($authordata->description); ?> </div> <?php } ?> <div class="current-author__social-profiles"> <?php $social_profiles = stag_get_user_social_profiles($author_id); $default_fields = stag_custom_user_fields(); if (count($social_profiles)) { foreach ($social_profiles as $slug => $url) { echo '<li class="' . esc_attr($slug) . '"><a href="' . esc_url($url) . '" title="' . esc_attr(ucfirst($slug)) . '"><i class="fa ' . $default_fields[$slug]['class'] . '"></i></a></li>'; } } if ('' != ($author_url = get_the_author_meta('user_url'))) { echo '<li class="website"><a href="' . esc_url($author_url) . '" title="' . esc_attr__('Website', 'stag') . '"><i class="fa fa-globe"></i></a></li>'; } ?> </div> </div><!-- .page-header__content --> </section><!-- .page-header --> <?php $query = new WP_Query(array('author' => $author_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10));