Skip to content

Instantly share code, notes, and snippets.

@gasatrya
Created July 16, 2013 04:07
Show Gist options
  • Save gasatrya/6005684 to your computer and use it in GitHub Desktop.
Save gasatrya/6005684 to your computer and use it in GitHub Desktop.
Add custom fields to the author profile fields WordPress
<?php
add_filter( 'user_contactmethods', 'my_new_contactmethods', 10, 1 );
/**
* Add custom fields to the author profile fields
*
*/
function my_new_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
$contactmethods['facebook'] = 'Facebook'; //add Facebook
return $contactmethods;
}
/* Display the field option 1 */
the_author_meta( 'facebook', $current_author->ID );
/* Display the field option 2 */
$current_author = get_userdata( get_query_var( 'author' ) );
?>
<p>
<a href="<?php echo esc_attr( $current_author->facebook );?>">Facebook</a>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment