php - Wordpress show only one post for each author ( Page loads too slow ) -
i want show 1 latest post each author , found code working. however, takes long load page since have on 100k authors , 100k posts in database. how can optimize code?
<?php //displaying latest post per author on front page function filter_where($where = '') { global $wpdb; $where .= " , wp_posts.id = (select id {$wpdb->prefix}posts p2 p2.post_status = 'publish' , p2.post_author = {$wpdb->prefix}posts.post_author order p2.post_date desc limit 0,1)"; return $where; } add_filter('posts_where', 'filter_where'); query_posts($query_string); //the loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ... ?>
here original article code.
http://www.dbuggr.com/smallwei/show-latest-post-author-wordpress-front-page/
Comments
Post a Comment