Listing authors and date archive from custom post type

This should have been two different questions but anyway,

I needed to use wp_list_authors for custom post type so i created this function:

function get_authors_ids_by_post_type($type = null,$args=""){
    if ($type === null) return;
    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="$type" AND " . get_private_posts_cap_sql( $type ) . " 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;
}

which is the same as wp_list_authors but you can also define the post type.

as for the date based archive you get a 404 because your rewrite is wrong, mainly because of the way the links are generated and secondly because of your rewrite rule which uses blog-date and that is not defined anywhere in the query itself.

to get your desired permalink working you need to use another hooked function :

add_filter('get_archives_link', 'blog_archive_links');

function blog_archive_links($html){
    $home_url = home_url();
    $home_url_with_blog  = $home_url .'blog/';
    return str_replace($home_url,$home_url_with_blog,$html);
}

this should set the links so all that is left is to make them work 🙂

So your rewrite rules should look something like this:

//to match http://www.example.com/blog/2011/12/1/ use
add_rewrite_rule('^blog/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$','index.php?post_type=blog&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]','top');

//to match http://www.example.com/blog/2011/12/1/page/2 use
add_rewrite_rule('^blog/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$','index.php?post_type=blog&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&page=$matches[4]','top');

//to match http://www.example.com/blog/2011/12/ use
add_rewrite_rule('^blog/([0-9]{4})/([0-9]{1,2})/(?$','index.php?post_type=blog&year=$matches[1]&monthnum=$matches[2]','top');

//to match http://www.example.com/blog/2011/12/page/2 use
add_rewrite_rule('^blog/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$','index.php?post_type=blog&year=$matches[1]&monthnum=$matches[2]&page=$matches[3]','top');