WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Now the order is: apples, oranges, pears.
But I want to be in a random order, for ex: oranges, apples, pears.
Or to write them in a order that I want.

Is this possible?

Taxonomy is like that:

        'fruits' => array(
        'post-types' => array('products'),
        'name' => 'Fruits',
        'slug' => 'fruits',
        'type' => 'tags' ),
share|improve this question
Show us the whole query. – Wyck Jan 24 '13 at 5:45
up vote 0 down vote accepted

[SOLVED] This do the Job:

function set_the_terms_in_order ( $terms, $id, $taxonomy ) {
    $terms = wp_cache_get( $id, "{$taxonomy}_relationships_sorted" );
    if ( false === $terms ) {
        $terms = wp_get_object_terms( $id, $taxonomy, array( 'orderby' => 'term_order' ) );
        wp_cache_add($id, $terms, $taxonomy . '_relationships_sorted');
    return $terms;
add_filter( 'get_the_terms', 'set_the_terms_in_order' , 10, 4 );

function do_the_terms_in_order () {
    global $wp_taxonomies;  //fixed missing semicolon
    // the following relates to tags, but you can add more lines like this for any taxonomy
    $wp_taxonomies['post_tag']->sort = true;
    $wp_taxonomies['post_tag']->args = array( 'orderby' => 'term_order' );    
add_action( 'init', 'do_the_terms_in_order');

Credit goes here: Change order of Custom Taxonomy List

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.