Skip Navigation

[Resolved] Creating a View based on custom field

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.

This topic contains 7 replies, has 2 voices.

Last updated by andrewB-7 3 months, 1 week ago.

Assigned support staff: Beda.

Author
Posts
#1605257

Hi there.

I really hope that you can help me.

I am trying to create a custom query which lists posts in order of the date field created in Elementor.

I have put all of the information below which I think you need, but please tell me anything I've missed.

Post type: courses
Taxonomy: coursetypes
Taxonomy term: one-day-courses
Date field (which I need to query) by): start-date-for-course
Order: Ascending order (i.e. next course first, later courses follow from there)

Thank you so much for your time.
Andrew.

#1605579

It depends a lot on what that field stores in the database
Toolset Types Date Fields will store a timestamp and Views is made to deal with Types Date Fields - but also with Post Date as added by WordPress, which is not a timestamp.

You will need to know what your field stores, and then you can add a Query Filter (or Front End Search) by that Field, in any View.
Doing so you'll have to specify the "type" to query by, so for example, DATE or NUMBER (in Toolset's case, it'd be NUMBER, as it is a timestamp, and those are merely numeric values increasing from 0 to n)

To know what your Date Field by Elementor stores, you best consult the Elementor Support.
Please let me know if you need help with Types Date Fields (in case you want to switch) or with the Query for the field

#1605599

Hi Beda,

It is a Toolset date field, created in Tooolset Types. Sorry that was a typo above.

Can you please help based on that?

#1605641

Ah, in this case, you can simply add a New View, either with a Block or thru the classic Editor as you prefer.

In the View, you'd then have to add a Query filter by that Date field and choose NUMBER as a format to compare.
In Blocks, this is done in the View Block Inspector "Query Filter" settings, and in classic Views, that's done in the Query Filter settings you will see on the screen.

You can read more on date queries:
https://toolset.com/documentation/user-guides/views/date-filters/

Note this is different when you query Post Date:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-date/

Now, that is to add a Query Filter (speak: a search or a filter by).
To order your list by that field, you have to alter the Ordering options of the View (again in Blocks this is done in the Block inspector)
There, you would then select your Custom Field, which will default to "as a number" in the comparison format.

This will allow ordering by that date field

#1605653

Does Toolset date field not store in meta_key?

#1606757

I don't understand your question.

meta_key is a property of a postmeta entry.
the meta_key is basically usually the slug of the field (but does not have to be).
Every postmeta entry in a WordPress Database has a meta_key, and meta_keys are totally unrelated to 3rd party Date fields of any kind if used in Views.

A meta_key just defines the single item in the database so you can "get" and "update" it.

Never any data is saved in a meta_key, but always data of the field is saved in the meta_value column.

Can you elaborate on the background of this question? It could be a misunderstanding we can clarify.

PS:
The Toolset Date Field will be in your postmeta database table with meta_key "wpcf-your_field_slug" where your_field_slug is the slug of the date field you saved in Toolset > Custom Fields.

However, this is irrelevant both for Queries or Ordering.

#1608423

Okay, thank you Beda.

#1613031

My issue is resolved now. Thank you!