WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 2 years ago

#30244 closed enhancement (maybelater)

Category / Taxonomy Term "Menu Order"

Reported by: Howdy_McGee Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Taxonomy Keywords:
Focuses: ui, administration Cc:

Description

Currently there is only a handful of ways to order taxonomy terms: id, name, slug, and term_group. None of these give a precise custom order to your terms. Since term_group isn't used by anything in core ( to my knowledge ) I propose we change it to term_menu_order ( or leave it the same name ) and add a new field for ordering. In the wild you can easily do this by a little customization but I feel as though it would be a nice built in feature so users have pin-point precision on what order they would like terms to appear if they choose so.

Attachments (2)

term_menu_order.jpg (22.0 KB) - added by Howdy_McGee 6 years ago.
Example of Working Term Order via Term Group
term_order.jpg (30.2 KB) - added by Howdy_McGee 6 years ago.
Better representation of Term Order

Download all attachments as: .zip

Change History (18)

@Howdy_McGee
6 years ago

Example of Working Term Order via Term Group

#1 @joedolson
6 years ago

  • Focuses accessibility removed

@Howdy_McGee
6 years ago

Better representation of Term Order

#2 @boonebgorges
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

A couple thoughts:

  • There's a 'term_order' field in wp_term_relationships. See #5857 [6851]. Because this is stored in the relationships table, it's designed for use with reference to a specific item. You could hack together something that would use this field to make the terms themselves orderable, though it would be clumsy. (For one thing, it'd only be possible for a term to have an order if it were attached to at least one object.)
  • We can't repurpose 'term_group'. Core may not use it, but surely plugins do.
  • If we had termmeta, we could do this without a schema change (wouldn't scale very well, but it probably wouldn't matter in most cases). See #10142.
  • Term order is likely only useful in a very small subset of cases. We sorta deepmhasize menu_order in the post/page interface, and IMO the use cases there are more obvious, so I assume we'd want something even less obtrusive. This kinda makes me think this'd be better suited for a plugin, though without termmeta, it's not super obvious how the plugin would work.

I'm going to close this as maybelater, because I don't see any realistic progress on this front until we get termmeta in place, at which point maybe we can talk about a feature plugin that fleshes out all pieces of the term_order UI.

#4 @benoitchantre
5 years ago

Term meta is now part of the core.
@boonebgorges: can you reopen this ticket?

#5 follow-up: @boonebgorges
5 years ago

@benoitchantre Yes, termmeta is now part of core, but I'm not sure that we should reopen the ticket. What is the use case for allowing terms to be ordered? Is it something that most users, or even a sizable minority of users, will want? It seems to me that termmeta is a good foundation for a plugin that allows terms to be ordered, but it doesn't strike me as a feature that's worthwhile for core (especially if it requires building a UI). See also #34996.

If you need a UI, you may also consider the existing plugin https://github.com/stuttter/wp-term-order. This plugin does *not* use termmeta to store its data.

#6 @benoitchantre
5 years ago

@boonebgorges When you use Wordpress as a CMS with custom post types and custom taxonomies, you might need to display the terms in a specific order (ex: a terms from a team taxonomy).
I think a basic implementation (support of menu order and a simple metabox like we have for posts and custom post types) could be part of the core and more sophisticated UI (drag and drop) could be left to plugins. With that in place, the plugins will have a standardized data to play with.

#7 @Howdy_McGee
5 years ago

I think a better solution would be to integrate a meta_query into functions like get_terms() so we can order by meta_value or the likes. Also, term_group is still widely unused.

#8 @SergeyBiryukov
5 years ago

  • Resolution changed from maybelater to duplicate

Duplicate of #9547.

#9 follow-up: @dboulet
5 years ago

I disagree, this is not the same as #9547. That ticket is about prioritizing terms that are attached to posts — meaning that the order is set per post. This ticket is about setting an order for the terms in a more general way — allowing, for example, to display terms in a custom order when displayed as a list in a sidebar.

#10 in reply to: ↑ 9 @SergeyBiryukov
5 years ago

  • Resolution changed from duplicate to maybelater

Replying to dboulet:

This ticket is about setting an order for the terms in a more general way — allowing, for example, to display terms in a custom order when displayed as a list in a sidebar.

Thanks, at a glance it seemed to me that #9547 covered this as well.

#11 in reply to: ↑ 5 @theMikeD
4 years ago

Replying to boonebgorges:

Yes, termmeta is now part of core, but I'm not sure that we should reopen the ticket. What is the use case for allowing terms to be ordered? Is it something that most users, or even a sizable minority of users, will want?

The plugin that uses term_order to allow users to manually set the term order ( https://wordpress.org/plugins/custom-taxonomy-order-ne/screenshots/ ) has 10,000+ active installs. So I'd say that while it's not a barn burner, there is clearly a use case. So what is the reason to not do this?

Speaking of a use case, here you go: I have CPT for tracking projects, and a CT for tracking team members. Some team members are jr, some are sr, and the senior ones should be listed first. Manual term order is the solution here.

IMHO this needs to be re-opened.

Last edited 4 years ago by theMikeD (previous) (diff)

#12 @theMikeD
4 years ago

It would seem that #34996 solves this via term_meta. Which is good, but it's still strange that term_order can't be used to achieve this result since it seems that what it is intended for. Anyway, carry on.

#13 @boonebgorges
4 years ago

Correct: After #34996, it's possible to build a simple plugin that adds term_order term meta via some UI. You can then order get_terms() results by that key as follows:

$terms = get_terms( $taxonomy, array(
    'meta_key' => 'term_order',
    'orderby' => 'meta_value_num',
) );

There's no point in introducing the UI for adding term_order into core unless core actually takes advantage of that term_order somewhere. Where would that be? Eg: would the Categories widget have an option to sort by term order? Would term order be used as the default sort order for get_terms() in all contexts? Would template tags like get_the_tag_list() use term_order by default? Proposals are welcome, but until we have a solid proposal for the edit UX as well as specific core use cases, this remains clearly in plugin territory.

#14 follow-up: @theMikeD
4 years ago

Wouldn't the arguments be the same as those for menu_order or posts?

#15 in reply to: ↑ 14 @boonebgorges
4 years ago

Replying to theMikeD:

Wouldn't the arguments be the same as those for menu_order or posts?

menu_order is used all over the place in core, especially in nav menus.

#16 @boonebgorges
2 years ago

#44505 was marked as a duplicate.

Note: See TracTickets for help on using tickets.