Add author bio with social links to blog post

Often we like to add a author bio at the bottom of blog post. To do so we use external plugins. By adding few script to our theme function file we can easily create our own custom author bio for our blog post. Lets see what type of field we need to get user/author social links:

author links field screenshot

What we need to add in function file:

Now we will show the author bio with the social links we have added to admin section:

 

Lets discuss about the function we have used in this article:

  • __() function retrieves the translated string from the translate(). Usually get two parameter and the first parameter is required!
  • the wp_kses_post() and esc_url() functions are used to data sanitization.
  • get_user_by() function is used to get user data by field and data. The possible fields are ‘id‘, ‘slug‘, ‘email‘, ‘login‘ for first parameter.
  • get_the_author_meta() function returns the desired meta data for a user. If the specified meta field does not exist for this user, the empty string is returned.
  • get_user_meta() is used to retrieve a single meta field or all fields of user_meta data for the given user.

 

Share with:

Categories: Wordpress