[wp-hackers] sorting of array from $wpdb class

David Clark david at davidsaccess.com
Thu Sep 9 23:05:23 UTC 2004


Hi,

hopefully, this question will be clearer:

start by viewing two urls:
http://www.richardsnotes.org/archive.php
http://www.richardsnotes.org/archive.php?cat=7

The list in the leftmost div in  the 2nd url is generated by:
           $categories = $wpdb->get_results("SELECT * FROM 
$tablepost2cat WHERE category_id = $cat");
           if ($categories) {
                foreach ($categories as $post2category) {
                     $posts = $wpdb->get_results("SELECT * FROM 
$tableposts WHERE $post2category->post_id = ID".$where);
                     //$category_realname = $wpdb->get_row("SELECT 
cat_name FROM $tablecategories WHERE cat_ID = 
$post2category->category_id");
                     //print_r($category_realname);
                     global $category_name;
                     $category_name = $post2category->category_id;
                     if ($posts) {
                          foreach ($posts as $post) {
                               start_wp();
                               archive_header('<div 
class="list_heading">', '</div>'); ?>
                               <li> <a href="<?php echo 
get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: 
<?php echo $post->post_name; ?>"><?php echo the_title(); ?></a></li>
                               <?php

                          }
                     }
                }
           }

I wont $post to be sorted by post_date. is changing the sql for 
$categories the best way?

dc




More information about the hackers mailing list