搜索热词

WordPress中文社区 > , > WordPress获取指定用户,指定文章类型及指定分类ID的文章数量

WordPress获取指定用户,指定文章类型及指定分类ID的文章数量

发布于09月07日 被浏览 596 次
//获取用户文章等数据
function get_author_postsdate( $user_id, $cat_id,$post_type ) {
    if ($user_id) {
         $author_query = new WP_Query( 'posts_per_page=-1&cat='.$cat_id.'&post_type='.$post_type.'&author='.$user_id );
         $i=0;
         while ($author_query->have_posts()) : $author_query->the_post(); ++$i; endwhile; wp_reset_postdata();
         return $i;
     }
     return false;
}

使用的时候直接前台调用<?php echo  get_author_postsdate( '1', '1','post');?>

点赞 收藏 打赏 分享

0 条评论

无意义的评论将很快被删除,账号将被禁止发言。 发表评论 0/500
 
  1. 还没有任何评论,你来说两句吧