最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - There any way to get de percentage of number of post by user and category?

programmeradmin2浏览0评论

This is the thing, Id like to get the % of number of posts from a specific user and category, additionally choosing from 'n' last days, or get for 'n' posts.

Example:

  • A: User 2 have a 10% of total CARS category on last 15 days.
  • B: User 2 have a 10 posts for CARS category on last 20 CARS category posts.
  • C: User 2 have a 10 posts for CARS category posted since 15 days ago.

Any of these examples, I think that knowing the correct code, the whatever result is easy to use.

I have next code, but, I get only % of TOTAL of post for selected category (I don't know how to choose from how many days ago or from how many posts of category):

function boz_tscount() {
    $args = array( 
        'author' => 2,
        'cat'    => 11,
    );
    $cat_total = get_category( 11 );
    $my_query  = new WP_Query( $args );
    $cat_count = $my_query->post_count;
    //get % = count / total * 100
    echo $cat_count / $cat_total->count * 100;
}
发布评论

评论列表(0)

  1. 暂无评论