Alter authors query to improve slow lookup on blogs with many users.
-
For blogs with lots of users (10,000+), your queries to lookup authors and author post counts take a really long time. I’m not sure how backwards compatible the below code snippet is, but it dramatically speeds up the plugin if you can use it.
$user_args = array(
‘fields’ => array(‘ID’, ‘user_nicename’),
‘who’ => ‘authors’
);
$wp_user_search = new WP_User_Query($user_args);
$authors = $wp_user_search->get_results();
$author_ids = array();
foreach($authors as $author) {
$author_ids[] = $author->ID;
}
$author_count = count_many_users_posts($author_ids);
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Alter authors query to improve slow lookup on blogs with many users.’ is closed to new replies.