0

I have a View set up for blog post content in Drupal 8. The blog posts were all posted at the same time but have different "year" tags attached to them based on when the post is relevant to the company, and I am trying to sort them starting with most recent year (2019 to 2014. I can't seem to get them to filter in the correct order based on the tags.

These are the steps I have already taken:

  1. Added a relationship with "Taxonomy: Terms on node". Selected the tags vocabulary.

enter image description here

  1. Added a sort criteria for taxonomy term - year (which is in the tags)

enter image description here

  1. Tagged all blog posts with the correct year (ranging from 2014-2019)

But the posts are still in a completely random order. Am I missing a step somewhere?

  • 1
    Hi, Jen. I'm a bit unclear on how you are using tags - does the "Tags" vocabulary only contain years (as terms)? Have you tried using the relationship "Taxonomy term referenced from [name of field]" instead of "Taxonomy terms on node"? – othermachines Mar 5 at 18:26
0

You don't need a Relationship to add the Tags sort (use the actual Tags field reference, not the generic "Terms on node").

But this way the results will be sorted by TID, not by term names. If your tags have been added chronologically then their TIDs will also be chronological and you can use this sort criteria (it doesn't matter if asc. or desc.).


But if your TIDs for years terms are mixed up you have to sort by term name. This is an alphabetical sort, not a numerical sort, but luckily it will work correctly in your "years" case.

To do that you have to:

  1. Add the Relationship for your tags field, you can require it since you only want nodes that have the years tag to appear
  2. Add Sort criteria Name from the Taxonomy term Category (it will automatically use the Relationship from above)

Now your results will be sorted by text 2015, 2016 etc.

  • There is the actual Name option you can choose from the list, it doesn't mean to substitute that with the name of your field, it literally means Name. Add the Name sorting criteria from Taxonomy term category. – prkos Mar 6 at 23:01
  • lol we were replying at the same time, I see you got it figured out. – prkos Mar 6 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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