Make WordPress Core


Ignore:
Timestamp:
01/06/2004 12:44:46 PM (22 years ago)
Author:
saxmatt
Message:

Reduce queries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-blog-header.php

    r726 r727  
    168168if ('' != $category_name) {
    169169    $category_name = preg_replace('|[^a-z0-9-/]|', '', $category_name);
     170    $tables = ", $tablepost2cat, $tablecategories";
    170171    $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
    171172    $whichcat = " AND (category_nicename = '$category_name') ";
     
    320321$posts = $wpdb->get_results($request);
    321322
     323
     324// Get the categories for all the posts
     325foreach ($posts as $post) {
     326    $post_id_list[] = $post->ID;
     327}
     328$post_id_list = implode(',', $post_id_list);
     329
     330$dogs = $wpdb->get_results("SELECT DISTINCT
     331    ID, category_id, cat_name, category_nicename, category_description
     332    FROM $tablecategories, $tablepost2cat, $tableposts
     333    WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
     334   
     335foreach ($dogs as $catt) {
     336    $category_cache[$catt->ID][] = $catt;
     337}
     338
     339// Do the same for comment numbers
     340
     341
    322342if (1 == count($posts)) {
    323343    if ($p || $name) {
Note: See TracChangeset for help on using the changeset viewer.