WordPress: Показать авторов таксономии в порядке количества сообщений

я хочу показать список авторов таксономии и упорядочить список по количеству сообщений. В конце я хочу показать изображения авторов разного размера в зависимости от количества их сообщений.

Вот что у меня есть (источник: http://blog.brianjohnsondesign.com/dropdown-list-of-authors-with-posts-in-category/):

<ul>
              <?php //Code to get a list of all authors with posts in this category, and then create a dropdown list of their names with links to their page

                    $category = get_queried_object();
                    $taxonomy_name = 'themen'; //Change to reflect the name of your custom taxonomy
                    $current_category = $category->slug;
                    $author_array = array();
                    $args = array(
                    'posts_per_page' => -1,
                    'post_type' => 'post', //Change to your custom post type
                    'tax_query' => array(
                            array(
                                'taxonomy' => 'themen', //Change to reflect the name of your custom taxonomy
                                'field' => 'slug',
                                'terms' => $current_category
                                ),
                                ),
                    'orderby' => 'author',
                    'order' => 'ASC'
                    );
                    $cat_posts = get_posts($args);
                    foreach ($cat_posts as $cat_post) :
                    if (!in_array($cat_post->post_author,$author_array)) {
                    $author_array[] = $cat_post->post_author;
                    }
                    endforeach;
                    foreach ($author_array as $author) :
                    $auth = get_userdata($author)->display_name;
                    $nicename = get_userdata($author)->user_nicename;
                    //echo '<li><a href="' . get_term_link( $category->slug, $taxonomy_name ) . '/' . $nicename . '">' . $auth . '</a></li>';
                    echo '<li><a href="/author/' . $nicename . '/">' . $auth . '</a></li>';
                    endforeach;
                    ?>
                </ul>

Это правильное направление? Я не уверен, как я могу заказать авторов. :(


person Cray    schedule 06.08.2014    source источник


Ответы (1)


Вы можете определенно использовать запрос WP для этого. Запрос WordPress — очень мощный инструмент, если вы используете его правильно. Или вы можете просто перечислить авторов, используя функцию WP под названием list_authors.

<?php wp_list_authors( $args ); ?> 



<?php $args = array(
'orderby'       => 'post_count', 
'order'         => 'DESC', 
'number'        => null,
'optioncount'   => false, 
'exclude_admin' => true, 
'show_fullname' => false,
'hide_empty'    => true,
'echo'          => true,
'feed'          => [empty string], 
'feed_image'    => [empty string],
'feed_type'     => [empty string],
'style'         => 'list',
'html'          => true,
'exclude'       => [empty string],
'include'       => [empty string] ); ?> 
person Domain    schedule 07.08.2014
comment
Да, но с функцией WP wp_list_authors я не могу перечислить только авторов в определенной категории/налоговом архиве. - person Cray; 07.08.2014