Plugin release: Tag or Category term_group Order

We are glad to announce our first plugin called Tag or Category term_group Order.

The purpose of this plugin is to group tags or categories from the WordPress dashboard. This allows queries that fetch terms to use ‘term_group’ as a sort order and and display them in a semantic way in archives and individual posts.

For example,

If we have three groups of categories for size, color and object, then categories displayed as

Small, Green, Table

Big, Blue, Chair

are more readable than

Table, small, green

Chair, big, blue

How to use  this plugin?

1. Install and activate the plugin from WordPress plugin repository.

2. Visit WordPress Dashboard -> Posts – > Categories. You will find an additional field called ‘group’ to add the group number.

3. Add this code where you need to display the categories by group order.

$args = array('orderby' => 'term_group', 'order' => 'ASC', 'fields' => 'all');

$terms = wp_get_object_terms($post->ID, 'category', $args );

$count = count($terms);

if($count > 0){

echo 'Posted in <ul id="catlist">';

foreach ($terms as $term) {

echo '<li><a href="'.get_term_link($term->slug, 'category').'">'.$term->name.'</a> .</li>';

}

echo '</ul>';

}

4. You can group and display tags in a similar way. Just use the word ‘tag’ instead of ‘category’ in the code above.

We made this by modifying the Term menu order plugin by James Lafferty. Thanks, James.

Hope  you find this useful. Please do share your comments and rate the plugin.

Download the plugin now

Comments

  1. jameslafferty says:

    Glad it was useful to you guys… It seems like my plugin is no longer working as of 3.2, and was wondering whether you had suffered from similar issues.

    Cheers,

    J.

  2. Hi James, good to see you here. Our plugin is working fine with the latest WP version.

Speak Your Mind