06-18-2010, 08:24 AM
|
|
|
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,430
|
Quote:
Originally Posted by cyber
Code:
$sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
"LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
"WHERE parent=5 AND taxonomy='category' ORDER BY name ASC";
$categoryList = $wpdb->get_results($sql);
echo categoryPrint($categoryList);
function categoryPrint($results, $multiple = "", $subcat_level = 0){
global $wpdb;
if(!$results){return;}
foreach($results as $a_cat){
if($multiple){
categoryPrintSelectItem($a_cat, $subcat_level);
}
else{
categoryPrintItem($a_cat, $subcat_level);
}
$sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
"LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
"WHERE parent=$a_cat->ID AND taxonomy='category' ORDER BY name ASC";
$sub_cats = $wpdb->get_results($sql);
categoryPrint($sub_cats, $multiple, $subcat_level + 1);
}
}
function categoryPrintSelectItem($a_cat, $subcat_level){
for($i = 0; $i < $subcat_level; $i++){
echo "?";
}
echo $a_cat->name."</option>\n";
}
function categoryPrintItem($a_cat, $subcat_level){
for($i = 0; $i < $subcat_level; $i++){
echo "{$a_cat->name}<br>";
}
if($subcat_level < 1){
echo "<b><h3>{$a_cat->name}</h3></b><br>";
}
}
Change this:
To the category's ID.
|
thats a sure messy way to do it, when you can do it with css.
have a look at the default wordpress css styling, theirs one for child cats.
http://digwp.com/2010/05/default-wor...-styles-hooks/
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
WP Stuff
|
|
|