在开发wordpress主题用户中心时想获取到当前已登录用户的文章数量和评论数量,自己一时没想出解决方法。
于是百度搜了搜,发现几行代码就能搞定,于是记录下来。
//当前登录用户
get_current_user_id();
// 或者
global $user_id;
//文章数量
count_user_posts($user_id )
//评论数量
global $wpdb;
$count_user_comments = $wpdb->get_var( $wpdb->prepare("Select count(comment_ID) from $wpdb->comments where user_id = %d", $user_id) );
var_dump($count_user_comments);
标题:WordPress获取当前登录用户的文章数量和评论数量
分类:WordPress教程
链接:https://www.wpjc.net/490.html
版权:wpToo教程网(wpToo.com)所分享发布内容,部分为网络转载,如有侵权请立即联系我们,我们第一时间删除并致歉!
lasix online furosemide price walgreens psype Blisp
order viagra by phone
cialis prices
order levitra online uk
buy generic cialis with paypal - Discount cialis online best tadalafil prices
buy furosemide tablets furosemide is prescribed for psype Blisp