Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display tags in the order added and do not reorder them on save #21589

Open
LeninZapata opened this issue Apr 14, 2020 · 17 comments
Open

Display tags in the order added and do not reorder them on save #21589

LeninZapata opened this issue Apr 14, 2020 · 17 comments
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Enhancement A suggestion for improvement.

Comments

@LeninZapata
Copy link

Hi, Gutenberg is ordering the tags alphabetically after saving, I don't want it to sort the tags, I need the tags in the order that I put them, I don't want it to sort it automatically.

ACmPOC6qta

@johngodley
Copy link
Contributor

This seems to be general WordPress behaviour, rather than specific to Gutenberg, and is the same in the classic editor.

How are you using the tag order? Your theme can show the tags in any order it wants, and this will appear in your post. How it appears in the editor shouldn't change that.

@LeninZapata
Copy link
Author

I have a plugin of related posts by tag, but the relation is not relevant because first look for the posts with the first tags stored alphabetically, and not the first main tag, that is to say for me the order of the tags are key because the first tag is the most relevant. So when saving everything, it is sorted alphabetically and this does not help me, any idea how to alter this?

@talldan
Copy link
Contributor

talldan commented Apr 20, 2020

The terms only seem to be shown alphabetically visually, but are stored in order added in the database, so I think this is really a design issue rather than a data one. It's a question of whether the best user experience is for this field to show the tags in order added or alphabetically.

That the tags are reordered on saving the post seems unusual to me.

I'll add the Needs Design Feedback label.

@talldan talldan added General Interface Parts of the UI which don't fall neatly under other labels. Needs Design Feedback Needs general design feedback. labels Apr 20, 2020
@LeninZapata
Copy link
Author

LeninZapata commented Apr 20, 2020

According to the database structure, I currently find it complicated that this can be ordered according to the order of the user.

What occurs to me that the IDs of the terms are stored in a wp_postmeta (only the ids) in a meta called '_tax_post_tag_orden' = 23,11,1,50 then this would have the order and with that you could play around a bit, for another tax without hierarchy the meta would be '_tax_mycuscomtax_orden' = 99,119,3,33 I suppose that there must be a filter at the moment of saving the post tags to be able to save this new wp_postmeta.

So when calling any function that has to do with tags, you can call the new parameter 'order' that will call the field '_tax_tag_orden' and return the IDs terms of this metapost.

$tags = get_tags(array(
  'hide_empty' => false,
  'order' => 'entered' // <= new param*
));

It is an idea but I think that there should be the possibility that the entered tags have the order entered. This greatly influences the related posts of plugins and themes since the first term would be the most prominent of the others.

@karmatosed
Copy link
Member

If someone set a specific order, I think expecting them to stay in that order makes senses. I would vote to not reorder.

@LeninZapata
Copy link
Author

You just have to add a function just after saving in, this function saves in the wp_postmeta table a meta called _tax_{taxonomy}_orden and as value the IDS of the terms ordered as the user put them.

@talldan talldan closed this as completed May 4, 2020
@talldan talldan reopened this May 4, 2020
@talldan talldan added [Type] Enhancement A suggestion for improvement. and removed Needs Design Feedback Needs general design feedback. labels May 4, 2020
@talldan talldan changed the title Problem Order Tags Display tags in the order added and do not reorder them on save May 4, 2020
@talldan
Copy link
Contributor

talldan commented May 4, 2020

I've reworded the title of this so that it can be treated as an enhancement.

#22048 has been opened since and seems very similar.

@gsarig
Copy link

gsarig commented Oct 18, 2020

I faced the same issue and saw that while there is the wp_term_relationships table, it doesn't get properly updated with the tags' order on post update. As a workaround, I hooked into the rest_after_insert_this-post_type to update the order manually. Here is a more detailed explanation of what I did, along with some code that seems to work fine so far.

BTW, as I mentioned on #22048 , having an option to reorder terms with drag-and-drop would be great. Additionally, for better accessibility, there could also be complementary navigation using arrows. Here's a very rough sketch to get the idea of what I mean:

image

@paaljoachim
Copy link
Contributor

There is a tags PR here that can be tested and commented on:
#30598

@annezazu
Copy link
Contributor

Noting that this still occurs in 10.6.1:

Screen.Recording.2021-05-17.at.10.27.01.PM.mov

@johnlomat
Copy link

Will this be implemented in the future?

@iolugovoy
Copy link

Any updates on this?

@benborges
Copy link

any update on this ?

@ejazrasool
Copy link

ejazrasool commented Dec 18, 2023

This needs fixing. Reordering of tags should be a choice, not default behaviour.

@siajupiter
Copy link

This needs fixing. any update?

@madfcat
Copy link

madfcat commented Feb 27, 2024

Can we have this functionality?

@gsarig mentioned a workaround and it does what we need. But the tags still are ordered in Block Editor.
Is there a way to order them accordingly to the term order column from the DB or at least to stop sorting the tags while adding them in the Block Editor?

UPD: The tags can be sorted from the Posts -> All Posts -> Quick Edit.
I use this solution for now. But it is annoying that we do not have this functionality in the Block Editor. Definitely must have.

@Paktas
Copy link

Paktas commented Aug 28, 2024

The editor should NOT change the order of tags upon saving.
Suggest to use term_order column for preserving the tag sequence data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests