WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
[resolved] How to change order of taxonomies on the page? (2 posts)

  1. andyy
    Member
    Posted 3 years ago #

    Is it possible to order the taxonomies, by their ID or perhaps even more usefully by Description?

    $cats = get_categories('taxonomy=my_taxonomy_category');
    foreach ( $cats as $c ) {
    $url = get_category_link( $c->term_id );
    echo '<h2>name . '" >'.$c->name.'</h2>';
        $img = $taxonomy_images_plugin->get_image_html( 'thumbnail', $c->term_taxonomy_id );
        if( !empty( $img ) )
            print '' . $img . '';
    }
  2. andyy
    Member
    Posted 3 years ago #

    After thinking about it, I realised this is nothing to do with this plugin. I found a way to sort the category array by its description field, so I can now give that field a number to define its category order.

    function sortStdArray($cats,$index){
     $sort=array();
     $return=array();
     for ($i=0; isset($cats[$i]); $i++)
     $sort[$i]= $cats[$i]->{$index};
     natcasesort($sort);
     foreach($sort as $k=>$v)
     $return[]=$cats[$k];
     return $return;
     }
     $cats = sortStdArray($cats,"description");

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic