向当前主题的 Functions.php 文件添加代码
在 WordPress 管理仪表盘,单击外观> 主题编辑器(编辑主题),然后从右侧菜单中选择 Functions.php。将下面的代码复制到 Functions.php 的底部。
function output_user_count() {
$usercountdata = count_users();
$alluser = $usercountdata['total_users'];
return $alluser;
}
add_shortcode('allusercount', 'output_user_count');
如果要显示用户数据,只需要引用下面的短代码:
[allusercount]
我们可以将上面的短代码,添加到文章、页面和小工具等位置,此代码将显示当前的注册用户总数。
使用示例:
目前,本网站的注册用户数为<b> [allusercount]</b>。
作者:牛奇网,本站文章均为辛苦原创,在此严正声明,本站内容严禁采集转载,面斥不雅请好自为之,本文网址:https://www.niuqi360.com/wordpress/show-number-of-registered-users-in-wordpress/