纯代码实现wordpress中显示注册用户总数教程

简介

不知道你有没有想过要在woredpress当中显示注册的用户数量呢,一般来说这个功能用的不是很多,可能有的站

长会需要吧。那么就做个笔记写一下方法如何用代码实现wordpress中显示注册用户总数。

 

教程

代码如下,插入到functions.php文件档中,或者使用 snippets来管理代码片段(好处换主题代码依旧生效)

// Function to return user count
function wpb_user_count() { 
$usercount = count_users();
$result = $usercount["total_users"]; 
return $result; 
} 
// Creating a shortcode to display user count
add_shortcode("user_count", "wpb_user_count");

再使用短代码,添加到页面或者文章以及小工具当中,就会显示了

[user_count]

阅读剩余
THE END