custom-post-type-ui icon indicating copy to clipboard operation
custom-post-type-ui copied to clipboard

CPTUI-specific taxonomy ordering.

Open tw2113 opened this issue 9 years ago • 6 comments

Provide a field on taxonomies that set the order in which they should appear in the menu.

This is not a field that will be passed into the register_* functions, but would instead be used to do an array_sort() before the foreach that registers each taxonomy. This would allow a level of control for the user, without altering how we save object data and without forcing need to provide shuffling before save.

tw2113 avatar Aug 29 '16 15:08 tw2113

As far as my research goes, there is no plugin on the market, that can handle this. Would be great to see this, in my case: my frontend metaboxes are based on custom code, to the default order of the taxonomies. If we could change the default order, custom code could stay small, without selecting each box by another.

onlineatwork avatar Feb 07 '21 03:02 onlineatwork

Not quite sure how the order of fetching and display of details on the frontend is related at all to the order of registration but definitely willing to be enlightened and educated here. Especially with regards to metaboxes.

This opened enhancement issue is mostly around just being able to specify the order in which we register the taxonomies. I'm definitely going to want to be careful with this one in case people haven't specified any values. Not quite sure how I'll ultimately handle, if I implement at all.

I appreciate any information you can provide in regards to your ideas here, so that I can ensure educated decisions.

tw2113 avatar Feb 07 '21 03:02 tw2113

i posted the code of my case, on your WP support forum If you could delete it there, after maybe take a local copy, this would be great. Or set the post as private. Thats how in my case, taxonomie metaboxes are created and how the order is set. maybe this helps you to get a deeper understanding. I am not so into coding, but i noticed that the order is same on your backend, as it is on the Plugin menu, of the Post type the tax. are releated to.

onlineatwork avatar Feb 07 '21 03:02 onlineatwork

Is it possible to hook into admin_menu and reorder the submenu array... ?

eg:

add_action('admin_menu', 'change_taxonomy_order');

function change_taxonomy_order() {
    global $submenu;
    $taxonomy1 = 'edit-tags.php?taxonomy=artist&post_type=post';
    $taxonomy2 = 'edit-tags.php?taxonomy=genre&post_type=post';
    $submenu['edit.php'][16] = array($taxonomy1, 'Artist');
    $submenu['edit.php'][17] = array($taxonomy2, 'Genres');
}

PS. I have historically used Admin Menu Editor Pro, which can reorder plenty, but it feels like an extra add-on and will naturally leave database entries.

PPS. On the forum, you said: "it’s really based on the order in which they got registered with CPTUI". What determines the "order"? How are the taxonomy registrations stored in the DB? Are the CPT UI taxonomy profiles stored in such a way that they have IDs, ie which could be manually edited to fake the order one time?

robertandrews avatar Apr 06 '23 14:04 robertandrews

What determines the "order"? How are the taxonomy registrations stored in the DB? Are the CPT UI taxonomy profiles stored in such a way that they have IDs, ie which could be manually edited to fake the order one time?

First in the saved option array, first to get reached when iterating over the saved option that we pass in to register_taxonomy()

You could use the CPTUI tools menu and the "Taxonomies" tab to grab a JSON version of the option and then re-order, and re-import to do a quick manual reordering.

You probably could do that with the admin_menu hook but I'm not sure that's a route I want to attempt to take for everyone.

tw2113 avatar Apr 06 '23 14:04 tw2113

You could use the CPTUI tools menu and the "Taxonomies" tab to grab a JSON version of the option and then re-order, and re-import to do a quick manual reordering.

Great idea - thanks.

robertandrews avatar Apr 07 '23 10:04 robertandrews