get_results("SELECT $wpdb->posts.ID,$wpdb->posts.post_title,$wpdb->term_relationships.object_id,$wpdb->term_relationships.term_taxonomy_id,$wpdb->term_taxonomy.term_id FROM $wpdb->posts,$wpdb->term_relationships,$wpdb->term_taxonomy WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'page' AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $cat");
return $pages;
}
// Lists all categories, with a sublist of pages under each category.
function cw_listcategories() {
global $wpdb;
$categories = get_categories('hide_empty=0');
foreach($categories as $category) {
$catid = $category->cat_ID;
echo '
'.$category->name.'
';
echo '
';
$pages = cw_getpagesbycat($catid);
foreach($pages as $page) {
echo '