Advertisement
Guest User

WP get_author_posts_url

a guest
Apr 14th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. function get_author_posts_url($author_id, $author_nicename = '') {
  2.     global $wp_rewrite;
  3.     $auth_ID = (int) $author_id;
  4.     $link = $wp_rewrite->get_author_permastruct();
  5.  
  6.     if ( empty($link) ) {
  7.         $file = home_url( '/' );
  8.         $link = $file . '?author=' . $auth_ID;
  9.     } else {
  10.         if ( '' == $author_nicename ) {
  11.             $user = get_userdata($author_id);
  12.             if ( !empty($user->user_nicename) )
  13.                 $author_nicename = $user->user_nicename;
  14.         }
  15.         $link = str_replace('%author%', $author_nicename, $link);
  16.         $link = home_url( user_trailingslashit( $link ) );
  17.     }
  18.  
  19.     $link = apply_filters('author_link', $link, $author_id, $author_nicename);
  20.  
  21.     return $link;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement