| @@ -42,8 +42,9 @@ | ||
| 42 | 42 | * @param array $instance Instance |
| 43 | 43 | */ |
| 44 | 44 | public function widget($args = array(), $instance = array()) |
| 45 | 45 | { |
| 46 | + wp_enqueue_style('bbpc-forum'); | |
| 46 | 47 | |
| 47 | 48 | // Get widget settings |
| 48 | 49 | $settings = $this->parse_settings($instance); |
| 49 | 50 | |
| @@ -61,9 +62,10 @@ | ||
| 61 | 62 | 'posts_per_page' => (int) $settings['max_shown'], |
| 62 | 63 | 'ignore_sticky_posts' => true, |
| 63 | 64 | 'no_found_rows' => true, |
| 64 | 65 | 'update_post_term_cache' => false, |
| 65 | - 'update_post_meta_cache' => false | |
| 66 | + // The loop reads each reply's topic/author meta; load it in one query. | |
| 67 | + 'update_post_meta_cache' => true | |
| 66 | 68 | )); |
| 67 | 69 | |
| 68 | 70 | // Bail if no replies are found |
| 69 | 71 | if (!$widget_query->have_posts()) { |
| @@ -68,8 +70,11 @@ | ||
| 68 | 70 | // Bail if no replies are found |
| 69 | 71 | if (!$widget_query->have_posts()) { |
| 70 | 72 | return; |
| 71 | 73 | } |
| 74 | + | |
| 75 | + // Parent topics are used for titles and links; fetch them together. | |
| 76 | + _prime_post_caches(array_unique(wp_list_pluck($widget_query->posts, 'post_parent')), false, true); | |
| 72 | 77 | |
| 73 | 78 | echo $args['before_widget']; |
| 74 | 79 | |
| 75 | 80 | if (!empty($settings['title'])) { |