使用“终极会员”和“共同作者”时显示用户帖子计数

问题描述 投票:0回答:1

我正在使用插件最终成员和共同作者,并在帖子标签的作者页面中我试图显示用户使用此行写的帖子数量

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy' => 'author',
            'field' => 'slug',
            'terms' => $user_login
        )
    ),
);
$author_query = new WP_Query( $args );

if ( $author_query->have_posts() ) :
    while ( $author_query->have_posts() ) : $author_query->the_post();

    // Do your presentation

    endwhile;
endif;

非常感谢您对正确代码的帮助

wordpress
1个回答
0
投票

你需要一个柜台。

   $args = array(
            'post_type' => 'post',
            'tax_query' => array(
                array(
                    'taxonomy' => 'author',
                    'field' => 'slug',
                    'terms' => $user_login
                )
            ),
        );
        $author_query = new WP_Query( $args );

        $count=0;

        if ( $author_query->have_posts() ) :  
            while ( $author_query->have_posts() ) : $author_query->the_post();

            // Do your presentation

             $count++; 

           endwhile;

        endif;

 echo $count;
© www.soinside.com 2019 - 2024. All rights reserved.