1

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.