Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ”$作者->显示您的姓名。”'; } }_Php_Wordpress - Fatal编程技术网

Php ”$作者->显示您的姓名。”'; } }

Php ”$作者->显示您的姓名。”'; } },php,wordpress,Php,Wordpress,我发现的另一种方法是执行以下操作(我发誓之前找不到类似的操作): $authors=get_users('role=author&orderby=display_name&order=ASC'); foreach($authors作为$author的作者){ 如果(计数用户帖子($author->ID)>0){ echo“”.$author->display_name.”; } } 谢谢,这是一个很好的建议,但你知道如何编辑现有函数以包含id吗?刚刚看到你的更新答案,我从未尝试过,因为我最终找到

我发现的另一种方法是执行以下操作(我发誓之前找不到类似的操作):

$authors=get_users('role=author&orderby=display_name&order=ASC');
foreach($authors作为$author的作者){
如果(计数用户帖子($author->ID)>0){
echo“
  • ”.$author->display_name.
  • ”; } }
    谢谢,这是一个很好的建议,但你知道如何编辑现有函数以包含id吗?刚刚看到你的更新答案,我从未尝试过,因为我最终找到了另一种方法,我将发布,但感谢你的帮助!没问题。很好,您进行了一次很好的翻找,因为它总是有助于您下次陷入困境;)谢谢,这是一个很好的建议,但是你知道如何编辑现有的函数来包含id吗?刚刚看到你的更新答案,我从来没有尝试过,因为我最终找到了另一种方法,我将发布,但感谢你这么努力的帮助!没问题。很好,您进行了一次很好的翻找,因为它总是有助于您下次陷入困境;)
    $authors = wp_list_authors('html=0&style=none&echo=0&exclude_admin=1&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC'); 
    
    $authors_array = explode(',', $authors);
    
    for ($j = 0; $j < count($authors_array); $j++)
    {
        echo '<li id="">'.$authors_array[$j].'</li>';
    }
    
    $authors = wp_list_authors('html=0&style=none&echo=0&exclude_admin=1&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC&includeauthorid=1');  
    
    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,
        'includeauthorid' => false 
    );
    
    $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( $includeauthorid)
            $name .= ' ('. $author_id .')';
    
        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;
    
    $authors = get_users('role=author&orderby=display_name&order=ASC');
    
    foreach ($authors as $author) {
        if (count_user_posts($author->ID) > 0) {
           echo '<li id="' . $author->ID . '">' . $author->display_name . '</li>';
        }
    }