Wordpress current month users

时间:2020-04-02 作者:Pooja

如何在wordpress中显示当月用户列表?

  <?php $blogusers = get_users( array( \'role\' => \'game\', \'order\' => \'DESC\', \'number\'  => 50) );
    foreach ( $blogusers as $user ) {  ?>

  <p class="cardname--text"><?php echo $user->display_name; ?></p>
  <?php } ?>


1 个回复
最合适的回答,由SO网友:Elex 整理而成

您可以使用get_users function 具有date_query !

$month_users = get_users(array(
    \'date_query\'        => array(
        array(
            \'after\' => \'first day of this month\',
            \'before\' => \'last day of this month\',
            \'inclusive\' => true
        ),
    ),
));
if(!empty($month_users))
{
    foreach($month_users as $k => $v)
    {
        echo \'User : \'.$v->display_name.\'<br>\';
    }    
}