Support » Fixing WordPress » wp_query order by term group

  • Hi everybody,

    I am working on a new theme right now, where I need some category ordering done.
    On one of the templates, I would need the following code to work:
    $custom_query = new WP_Query( array ( 'cat' => $catid , 'orderby' => 'term_group' ))

    It *has* to work with term_group somehow, and yes I’ve tried quite a few category order plugins, which don’t really work for what I need to do – my categories are ordered, but I just need to display the post they contain in the order of the categories.

    Thanks in advance, I’m really stuck on this one…


Viewing 2 replies - 1 through 2 (of 2 total)
  • term_group is not used by wordpress default : the value is 0 even for hierarchicals taxonomies. So it’s normal it has no effect

    The only place where WP currently sets term_group is in wp_insert_term() in wp-includes/taxonomy.php. The code there only runs when you specify an alias_of parameter when adding a term. In that case, the value of alias_of should be the slug of an existing term in the same taxonomy. Both the existing term and the new term, will be given the same term_group starting with 1, regardless of the term_id of the original term… if the original term did not have a term_group assigned, a new one will be created.

    All of that pretty much squelches any other use of the term_group column.

    It would be nice if terms had a sort_order column; that would do what you want, as well as letting us re-order built-in terms like Categories. Perhaps it could be added.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_query order by term group’ is closed to new replies.