wp_list_authors [ WordPress Function ]
wp_list_authors ( $args = '' )
| Parameters: |
|
| Links: | |
| Returns: |
|
| Defined at: |
|
List all the authors of the blog, with several options available.
- optioncount (boolean) (false): Show the count in parenthesis next to the author's name.
- exclude_admin (boolean) (true): Exclude the 'admin' user that is installed bydefault.
- show_fullname (boolean) (false): Show their full names.
- hide_empty (boolean) (true): Don't show authors without any posts.
- feed (string) (''): If isn't empty, show links to author's feeds.
- feed_image (string) (''): If isn't empty, use this image to link to feeds.
- echo (boolean) (true): Set to false to return the output, instead of echoing.
- style (string) ('list'): Whether to display list of authors in list form or as a string.
- html (bool) (true): Whether to list the items in html form or plaintext.
Source
<?php
function wp_list_authors($args = '') {
global $wpdb;
$defaults = array(
'orderby' => 'name', 'order' => 'ASC', 'number' => '',
'optioncount' => false, 'exclude_admin' => true,
'show_fullname' => false, 'hide_empty' => true,
'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
'style' => 'list', 'html' => true
);
$args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
$return = '';
$query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) );
$query_args['fields'] = 'ids';
$authors = get_users( $query_args );
$author_count = array();
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 )
$author_count[$row->post_author] = $row->count;
foreach ( $authors as $author_id ) {
$author = get_userdata( $author_id );
if ( $exclude_admin && 'admin' == $author->display_name )
continue;
$posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0;
if ( !$posts && $hide_empty )
continue;
$link = '';
if ( $show_fullname && $author->first_name && $author->last_name )
$name = "$author->first_name $author->last_name";
else
$name = $author->display_name;
if ( !$html ) {
$return .= $name . ', ';
continue; // No need to go further to process HTML.
}
if ( 'list' == $style ) {
$return .= '<li>';
}
$link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
if ( !empty( $feed_image ) || !empty( $feed ) ) {
$link .= ' ';
if ( empty( $feed_image ) ) {
$link .= '(';
}
$link .= '<a href="' . get_author_feed_link( $author->ID ) . '"';
$alt = $title = '';
if ( !empty( $feed ) ) {
$title = ' title="' . esc_attr( $feed ) . '"';
$alt = ' alt="' . esc_attr( $feed ) . '"';
$name = $feed;
$link .= $title;
}
$link .= '>';
if ( !empty( $feed_image ) )
$link .= '<img src="' . esc_url( $feed_image ) . '" style="border: none;"' . $alt . $title . ' />';
else
$link .= $name;
$link .= '</a>';
if ( empty( $feed_image ) )
$link .= ')';
}
if ( $optioncount )
$link .= ' ('. $posts . ')';
$return .= $link;
$return .= ( 'list' == $style ) ? '</li>' : ', ';
}
$return = rtrim($return, ', ');
if ( !$echo )
return $return;
echo $return;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp list authors « WordPress Codex
Description. Displays a list of the sites's authors (users), and if ...
codex.wordpress.org - WordPress › Support » Tags — wp_list_authors
wp_list_authors() and post types, 8, Clicknathan, 4 months ... massive user table causes fatal errors in php with wp_list_authors, 3, tikibah, 8 months ...
wordpress.org - wp_list_authors wordpress Author List want to fetch gravatar and bio ...
I was running wordpress blog with multiple user. So I created the ... Hey mate, check out the link below, I used this method and now have a list of ...
stackoverflow.com - How can I exclude specific authors from wp_list_authors
Oct 7, 2010 ... I want to have the authors listed like usual from wp_list_authors() but I know there are a couple of ones I would like to exclude from the list as ...
wordpress.stackexchange.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- ZoiX on "List some authors"
- ZoiX on "List some authors"
- Clicknathan on "wp_list_authors() and post types"
- schulte on "Listing authors that have written custom post types?"
- Daniel Fru?y?ski (sirzooro) on "wp_list_authors() and post types"
- Ipstenu on "wp_list_authors() and post types"
- schulte on "wp_list_authors() and post types"
- tikibah on "massive user table causes fatal errors in php with wp_list_authors"
- Ipstenu on "wp_list_authors() and post types"
- theoutdoors on "wp_list_authors() and post types"