4 * Get the author of the current post in the Loop.
5 * @global object $authordata The current author's DB object.
6 * @param string $deprecated Deprecated.
7 * @return string The author's display name.
9 function get_the_author($deprecated = '') {
11 return apply_filters('the_author', $authordata->display_name);
15 * Echo the name of the author of the current post in the Loop.
16 * @see get_the_author()
17 * @param string $deprecated Deprecated.
18 * @param string $deprecated_echo Echo the string or return it. Deprecated, use get_the_author().
19 * @return string The author's display name, from get_the_author().
21 function the_author($deprecated = '', $deprecated_echo = true) {
22 if ( $deprecated_echo )
23 echo get_the_author();
24 return get_the_author();
28 * Get the description of the author of the current post in the Loop.
29 * @global object $authordata The current author's DB object.
30 * @return string The author's description.
32 function get_the_author_description() {
34 return $authordata->description;
38 * Echo the description of the author of the current post in the Loop.
39 * @see get_the_author_description()
42 function the_author_description() {
43 echo get_the_author_description();
47 * Get the login name of the author of the current post in the Loop.
48 * @global object $authordata The current author's DB object.
49 * @return string The author's login name (username).
51 function get_the_author_login() {
53 return $authordata->user_login;
57 * Echo the login name of the author of the current post in the Loop.
58 * @see get_the_author_login()
61 function the_author_login() {
62 echo get_the_author_login();
66 * Get the first name of the author of the current post in the Loop.
67 * @global object $authordata The current author's DB object.
68 * @return string The author's first name.
70 function get_the_author_firstname() {
72 return $authordata->first_name;
76 * Echo the first name of the author of the current post in the Loop.
77 * @see get_the_author_firstname()
80 function the_author_firstname() {
81 echo get_the_author_firstname();
85 * Get the last name of the author of the current post in the Loop.
86 * @global object $authordata The current author's DB object.
87 * @return string The author's last name.
89 function get_the_author_lastname() {
91 return $authordata->last_name;
95 * Echo the last name of the author of the current post in the Loop.
96 * @see get_the_author_lastname()
99 function the_author_lastname() {
100 echo get_the_author_lastname();
104 * Get the nickname of the author of the current post in the Loop.
105 * @global object $authordata The current author's DB object.
106 * @return string The author's nickname.
108 function get_the_author_nickname() {
110 return $authordata->nickname;
114 * Echo the nickname of the author of the current post in the Loop.
115 * @see get_the_author_nickname()
118 function the_author_nickname() {
119 echo get_the_author_nickname();
123 * Get the ID of the author of the current post in the Loop.
124 * @global object $authordata The current author's DB object.
125 * @return int The author's ID.
127 function get_the_author_ID() {
129 return (int) $authordata->ID;
133 * Echo the ID of the author of the current post in the Loop.
134 * @see get_the_author_ID()
137 function the_author_ID() {
138 echo get_the_author_id();
142 * Get the email of the author of the current post in the Loop.
143 * @global object $authordata The current author's DB object.
144 * @return string The author's username.
146 function get_the_author_email() {
148 return $authordata->user_email;
152 * Echo the email of the author of the current post in the Loop.
153 * @see get_the_author_email()
156 function the_author_email() {
157 echo apply_filters('the_author_email', get_the_author_email() );
161 * Get the URL to the home page of the author of the current post in the Loop.
162 * @global object $authordata The current author's DB object.
163 * @return string The URL to the author's page.
165 function get_the_author_url() {
168 if ( 'http://' == $authordata->user_url )
171 return $authordata->user_url;
175 * Echo the URL to the home page of the author of the current post in the Loop.
176 * @see get_the_author_url()
179 function the_author_url() {
180 echo get_the_author_url();
184 * If the author has a home page set, echo an HTML link, otherwise just echo the author's name.
185 * @see get_the_author_url()
189 function the_author_link() {
190 if (get_the_author_url()) {
191 echo '<a href="' . get_the_author_url() . '" title="' . sprintf(__("Visit %s's website"), get_the_author()) . '" rel="external">' . get_the_author() . '</a>';
198 * Get the ICQ number of the author of the current post in the Loop.
199 * @global object $authordata The current author's DB object.
200 * @return string The author's ICQ number.
202 function get_the_author_icq() {
204 return $authordata->icq;
208 * Echo the ICQ number of the author of the current post in the Loop.
209 * @see get_the_author_icq()
212 function the_author_icq() {
213 echo get_the_author_icq();
217 * Get the AIM name of the author of the current post in the Loop.
218 * @global object $authordata The current author's DB object.
219 * @return string The author's AIM name.
221 function get_the_author_aim() {
223 return str_replace(' ', '+', $authordata->aim);
227 * Echo the AIM name of the author of the current post in the Loop.
228 * @see get_the_author_aim()
231 function the_author_aim() {
232 echo get_the_author_aim();
236 * Get the Yahoo! IM name of the author of the current post in the Loop.
237 * @global object $authordata The current author's DB object.
238 * @return string The author's Yahoo! IM name.
240 function get_the_author_yim() {
242 return $authordata->yim;
246 * Echo the Yahoo! IM name of the author of the current post in the Loop.
247 * @see get_the_author_yim()
250 function the_author_yim() {
251 echo get_the_author_yim();
255 * Get the MSN address of the author of the current post in the Loop.
256 * @global object $authordata The current author's DB object.
257 * @return string The author's MSN address.
259 function get_the_author_msn() {
261 return $authordata->msn;
265 * Echo the MSN address of the author of the current post in the Loop.
266 * @see get_the_author_msn()
269 function the_author_msn() {
270 echo get_the_author_msn();
274 * Get the number of posts by the author of the current post in the Loop.
275 * @global object $post The current post in the Loop's DB object.
276 * @see get_usernumposts()
277 * @return int The number of posts by the author.
279 function get_the_author_posts() {
281 return get_usernumposts($post->post_author);
285 * Echo the number of posts by the author of the current post in the Loop.
286 * @see get_the_author_posts()
289 function the_author_posts() {
290 echo get_the_author_posts();
294 * Echo an HTML link to the author page of the author of the current post in the Loop.
295 * @global object $authordata The current author's DB object.
296 * @see get_author_posts_url()
297 * @see get_the_author()
300 /* the_author_posts_link() requires no get_, use get_author_posts_url() */
301 function the_author_posts_link($deprecated = '') {
304 '<a href="%1$s" title="%2$s">%3$s</a>',
305 get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
306 sprintf( __( 'Posts by %s' ), attribute_escape( get_the_author() ) ),
312 * Get the URL to the author page of the author of the current post in the Loop.
313 * @global object $wpdb WordPress database layer.
314 * @global object $wp_rewrite WP_Rewrite
315 * @global object $post The current post in the Loop's DB object.
316 * @return string The URL to the author's page.
318 function get_author_posts_url($author_id, $author_nicename = '') {
319 global $wpdb, $wp_rewrite, $post;
320 $auth_ID = (int) $author_id;
321 $link = $wp_rewrite->get_author_permastruct();
323 if ( empty($link) ) {
324 $file = get_option('home') . '/';
325 $link = $file . '?author=' . $auth_ID;
327 if ( '' == $author_nicename ) {
328 $user = get_userdata($author_id);
329 if ( !empty($user->user_nicename) )
330 $author_nicename = $user->user_nicename;
332 $link = str_replace('%author%', $author_nicename, $link);
333 $link = get_option('home') . trailingslashit($link);
336 $link = apply_filters('author_link', $link, $author_id, $author_nicename);
342 * Get the specified author's preferred display name.
343 * @param int $auth_id The ID of the author.
344 * @return string The author's display name.
346 function get_author_name( $auth_id ) {
347 $authordata = get_userdata( $auth_id );
348 return $authordata->display_name;
352 * List all the authors of the blog, with several options available.
353 * optioncount (boolean) (false): Show the count in parenthesis next to the author's name.
354 * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by default.
355 * show_fullname (boolean) (false): Show their full names.
356 * hide_empty (boolean) (true): Don't show authors without any posts.
357 * feed (string) (''): If isn't empty, show links to author's feeds.
358 * feed_image (string) (''): If isn't empty, use this image to link to feeds.
359 * echo (boolean) (true): Set to false to return the output, instead of echoing.
360 * @param array $args The argument array.
361 * @return null|string The output, if echo is set to false.
363 function wp_list_authors($args = '') {
367 'optioncount' => false, 'exclude_admin' => true,
368 'show_fullname' => false, 'hide_empty' => true,
369 'feed' => '', 'feed_image' => '', 'echo' => true
372 $r = wp_parse_args( $args, $defaults );
373 extract($r, EXTR_SKIP);
377 // TODO: Move select to get_authors().
378 $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
380 $author_count = array();
381 foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) {
382 $author_count[$row->post_author] = $row->count;
385 foreach ( (array) $authors as $author ) {
386 $author = get_userdata( $author->ID );
387 $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
388 $name = $author->display_name;
390 if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
391 $name = "$author->first_name $author->last_name";
393 if ( !($posts == 0 && $hide_empty) )
399 $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
401 if ( (! empty($feed_image)) || (! empty($feed)) ) {
403 if (empty($feed_image))
405 $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
407 if ( !empty($feed) ) {
408 $title = ' title="' . $feed . '"';
409 $alt = ' alt="' . $feed . '"';
416 if ( !empty($feed_image) )
417 $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
423 if ( empty($feed_image) )
428 $link .= ' ('. $posts . ')';
432 if ( !($posts == 0 && $hide_empty) )
433 $return .= $link . '</li>';