Guest User

Untitled

a guest
Mar 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. add_shortcode('author-name', 'author_name_shortcode_handler');
  2.  
  3. function author_name_shortcode_handler($atts,$content=null){
  4. if (!is_single()) return;
  5.  
  6. global $wp_query;
  7. $user_id = $wp_query->post->post_author;
  8.  
  9. $name = get_user_meta($user_id, 'first_name', true) . ' ' . get_user_meta($user_id, 'last_name', true);
  10.  
  11. if (!empty($name))
  12. return $name;
  13. else
  14. return;
  15. }
Add Comment
Please, Sign In to add comment