Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author AndrewUlrich

    (@andrewulrich)

    You may want to do this on the database side every time you add a new category. Use the following pseudocode to get an idea of what to do:

    //get all parent term ids used by facetedsearch terms
    $query="SELECT DISTINCT tt.parent FROM ".$prefix."_term_taxonomy tt, ".$prefix."_facetedsearch fs WHERE fs.term_id=tt.term_id";
    
    //put all the parent_ids into an array, and loop through each parent id
    $parent_array = query_to_array($query);
    foreach($parent_array as $parent_id)
    {
       //get all facetedsearch terms with the same parent, ordered alphabetically
       $query2="SELECT fs.term_id, t.slug FROM ".$prefix."_term_taxonomy tt, ".$prefix."_facetedsearch fs, ".$prefix."_terms t WHERE fs.term_id=tt.term_id AND t.term_id=tt.term_id AND tt.parent_id=".$parent." ORDER BY t.slug";
    
       //put all the terms and slugs into an array
       $term_array = query_to_array($query);
       $index = 0;
       //assign the new order number to each term
       foreach($term_array as $key->$term)
       {
         $term_array[$key]['order'] = $index;
         $index++;
       }
       //do an update query to assign all these new order numbers to their entries in the facetedsearch table
       $query = "UPDATE ALL THESE THINGS HERE(".$term_array;
       do_query($query);
    }

    please remember the above is pseudocode and is designed only to get you started. If you figure it out, please consider sharing your code, and maybe I’ll incorporate it into the plugin.

    Thread Starter Selvester47

    (@selvester47)

    Totally lost me there.

    Are you saying theres nothiing I can do on the template side to sort the tags?

    Hi Andrew,

    I’m having the same problem unfortunately with the widget-listed tags being out of order.

    Is there no way that the tags can be ordered in alphabetical (or at least some predictable) order? They’re not in the order I added them in either, the order appears to be random.

    Thanks for your help.

    Thread Starter Selvester47

    (@selvester47)

    Open Faceted_search.php

    Find this line:

    $tags = $wpdb->get_results('SELECT t1.name, t1.term_id, t2.parent FROM '.$wpdb->terms.' t1, '.$wpdb->term_taxonomy.' t2, '.$wpdb->term_taxonomy.' t3 WHERE t2.term_id = t1.term_id AND t3.term_id=t1.term_id AND t3.taxonomy="post_tag" ORDER BY t2.parent DESC', ARRAY_A);}

    Add

    asort($tags);

    after that.

    Save and it displays the tags in Alpha order.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Faceted Search] Ordering of Tags in widget’ is closed to new replies.