[Plugin: My Category Order] use it manually
-
My client suddenly decided to rearrange his categories, and of course, neither ID nor NAME would get the required results.
So I installed My Category Order to get the job done.
But, since I didn’t use wp_list_categories() but cycled through the categories manually (needed descriptions, that’s why), I had to change some code to make use of the cool plugin. Old code:<?php global $wpdb; $i=0; $categories = $wpdb->get_results("SELECT $wpdb->terms.term_id AS id, name, description from $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id WHERE parent = '$cat' ORDER BY name ASC"); foreach($categories as $category) :?> <h1><a href="?cat=<?php echo $category->id; ?>"><?php echo $category->name; ?></a></h1> <?php echo $category->description; ?> <?php endforeach; ?>
New code:
<?php global $wpdb; $i=0; $categories = $wpdb->get_results("SELECT $wpdb->terms.term_id AS id, name, description, term_order from $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id WHERE parent = '$cat' ORDER BY term_order ASC"); foreach($categories as $category) :?> <h1><a href="?cat=<?php echo $category->id; ?>"><?php echo $category->name; ?></a></h1> <?php echo $category->description; ?> <?php endforeach; ?>
Note: I’m using term_order to sort.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[Plugin: My Category Order] use it manually’ is closed to new replies.