Skip Navigation

[Resolved] Taxonomy view not able to order by term field?

This thread is resolved. Here is a description of the problem and solution.

Problem:
A taxonomy View has shortcode attributes which indicate it should sort by a term meta field, but it is not working.

Solution:
Be careful how you add the orderby attribute to the View shorcode.

When referring to term meta, the correct attribute is

orderby="taxonomy-field-seniority"

where in this example "seniority" is the slug of the term meta field.

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 3 voices.

Last updated by chrisM-19 6 years ago.

Assisted by: Nigel.

Author
Posts
#1167291

I am trying to: Get my custom Taxonomy of Agents to sort by the custom term field of Seniority

Link to a page where the issue can be seen: hidden link

I expected to see: Agents ordered in ascending order as per the numeric value of the Seniority field but instead seems to default to alphabetic

Instead, I got: As above 🙂

Ps. Please note this site is part of a Multisite instance

#1167635

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please check now, I see the first record it displays has assigned the seniority level = 1. Is this your expected result?
=> hidden link

#1167638

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Chris

It seems to be working now.

I looked at the View and I could see the problem.

I wasn't able to reproduce on my local test site.

Looking at the debug details, I noticed that you have a Query Filter to specify which terms are included, and wondered if there were a problem combining this (which adds an include argument to the WP_Query) with ordering by a term field.

So I first deleted this Query Filter, which made no obvious difference, so I added it back.

Except, after adding it back it spontaneously started working.

Unless you were simultaneously changing things I'm not sure what happened, but it appears to be working, please confirm.

#1168023

Hi Nigel,

I've just managed to fix it!

For some reason the View presents correctly when using the shortcode: [wpv-view name="agent-view-for-team-pages"]

But not when using what I thought to be the more specific and correct shortcode: [wpv-view name="agent-view-for-team-pages" orderby="seniority" order="asc"]

Why would this be?

Thanks!
Chris

#1168562

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Chris

I just tried the same locally, and when inserting the View if you set the orderby argument, it says to use a term meta field for ordering you should specify orderby="taxonomy-field-seniority", it is not enough to say "seniority".

It is not especially intuitive, but a close reading of the description specifies this.

#1170282

Thanks a million, Nigel.

Not immediately obvious like you said but certainly something I'll not soon forget!

Cheers,
Chris