朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

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调用当前用户的文章/评论数量

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » WordPress调用当前用户的文章/评论数量

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #0

    hello!,I like your writing very much! share we communicate more about your post on AOL? I need an expert on this area to solve my problem. May be that’s you! Looking forward to see you. ラ ブ ド ー ル

  2. #0

    分秒帧: http://iraqilug.com/

    东南亚小野猫1年前 (2022-01-07)回复