Skip Navigation

[Resolved] Custom Search Filter | Order of the options

This support ticket is created 3 years, 2 months 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 12 replies, has 2 voices.

Last updated by Shane 3 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2311353

Tell us what you are trying to do?

We're trying to sort the values of the Custom Search Filter Field

Is there any documentation that you are following?

Nope, we couldn't see more documentation on how the "Order of the options" works.

Is there a similar example that we can see?

See here: hidden link

What is the link to your site?

Here: hidden link

#2311597

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

HI Loan,

Thank you for getting in touch.

I don't believe we have any additional documentation on thi.

However is the issue that your field is being sorted?

Please let me know.
Thanks,
Shane

#2312077

Hi,

The issue is still not resolved.

We need to know how this sorting option of the Custom Search Filter Field works so we can know how to approach this.

#2312127

Hi,

Just to add.

We're trying to sort the value of this Search filter to Publish Date.

The values are coming from Custom Post Type (Physician).

#2312291

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Not sure I understand the issue fully, however the ordering option on the filter should sort it based on the value of the filter.

In your case I see that your filter values are texts.

Can you let me know what kind of field this is ? Meaning the field that was created in our Toolset Types plugin.

Thanks,
Shane

#2312357

Hi,

This is a Single line field, see here: hidden link

What we are trying to do is to sort the field values from the post dates. Currently, this custom field is connected to a custom post type and we want to know if there is code that can sort the field values via post date.

If you go to this page: hidden link the post are being sorted via post date and we want the search field to do the same thing. (hidden link)

Are you able to help?

#2312509

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Ok thank you for the clarity.

Unfortunately no you are not able to sort the post field itself by the post date. Reason being the sorting is done based on attributes of the field and not attributes of the post that it i connected to.

Of course this can be done with some custom code to curate the field terms but this would be out of the scope of what we can provide as support.

Thanks,
Shane

#2318493

Hi Shane,

How about changing the Search Filter Field value from a custom field to Post Title or any relevant that we can sort the values via post date?

Any help would really appriciated.

Let us know. Thanks!

Best,
Paul

#2318561

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paul,

How about changing the Search Filter Field value from a custom field to Post Title or any relevant that we can sort the values via post date?

Unfortunately this still not work because as mentioned the fields are sorted by an attribute of the field, in this case the field is sorted by its value. Whatever the value is of that field this is what it will be sorted by.

Thanks,
Shane

#2318607

Hi Shane,

Is there any chance that we can change the attribute to post titles? or maybe do you have any other methods to help us achieve our goal?

Let us know. Thanks!

#2318645

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Loan,

Unfortunately no, the only thing I can think of is the use of taxonomies and then add a custom field to the taxonomy terms which will determine the order you want them to be retrieved by.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_get_terms_args

The function above is basically a wrapper function for.
https://developer.wordpress.org/reference/functions/get_terms/

Where the same arguments that you provide here can be used in the view filter function. This takes a bit of setup as you will need to setup the taxonomies as well as setup the numeric value of each taxonomy term so that they can be sorted correctly.

Please let me know if this helps.
Thanks,
Shane

#2319215

Hi Shane,

Thus using taxonomy requires using custom coding or will just use search filter field?

Best,
Paul

#2319479

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Paul,

Using taxonomies will allow you to generate the dropdown filters however with the hook that I sent you should be able to customize how the items are displayed. Meaning you should be able to sort the terms by a term meta value.

Thanks,
Shane