Show authors by post count within so many days
-
Hi,
I am using the below code to gather a list of authors that have NOT had a post (of any post types) published within the last 60 days.
<?php $args = array( 'role' => 'contributor', ); $blogusers = get_users( $args ); ?> <div class="opinionators" class="cf"> <div class="title m-all t-all d-all">More than 60 days inactive</div> <?php foreach ( $blogusers as $user ) { //echo "<pre>"; print_r($user); echo "</pre>"; $argsone = array( 'date_query' => array( //set date ranges with strings! 'after' => '60 days ago', 'before' => 'tomorrow', //allow exact matches to be returned 'inclusive' => true, ), 'author' => $user->data->ID, 'posts_per_page' => -1, 'post_type' => 'any' ); $twomonthposting = new WP_Query($argsone); $twomonth_post_count = $twomonthposting->found_posts; $argstwo = array( 'author' => $user->data->ID, 'posts_per_page' => -1, 'post_type' => 'any' ); $postingsone = new WP_Query($argstwo); $post_countone = $postingsone->found_posts; if ($twomonth_post_count == 0 && $post_countone > 3) { ?> DO STUFF <?php } wp_reset_query(); } ?>
I once had 50 contributors and this worked – now that I have 122 contributors it breaks before the footer.
I wonder if someone wouldn’t mind scanning their expert eye over this code and seeing if I’m doing something wrong or missing something? FYI the webpage is Old Writers of Roobla.
Thank you for any help you can offer.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Show authors by post count within so many days’ is closed to new replies.