Skip Navigation

[Resolved] Problem with sort by date

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

Problem:

I am trying to sort by date but it doesn't work.

Solution:

The client is displaying fields of another post type, it should be current post type.

Relevant Documentation:

This support ticket is created 5 years, 6 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Franck 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1245670

Hi,

I am trying to sort by date but it doesn't work.

Here is my page : hidden link

#1245698

Hello,

Thanks for the details, I can log into your website.

I assume we are talking about this post view "CONSEILLERS - vue liste lots":
hidden link

And in section "Loop Editor", the custom date field:
[types field='date-de-livraison' style='text' format='j F Y' item="@programme-lot.parent"][/types]

If it is, above post view is querying posts of post type "lots", but the custom field "date-de-livraison" is in another post type "programme", so it is expected result that order by this custom date field won't work.

Views plugin is using WordPress class WP_Query to query posts, according to wordpress document:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
'meta_value' - Note that a 'meta_key=keyname' must also be present in the query.

If you are going to order the result by a custom field, that custom field must be setup in the same custom post type "lots".

#1245714

Oh, i have changed the field [types field='date-de-livraison' style='text' format='j F Y'][/types]
Because the field is not a parent field, but what i see is an other problem, when a add a child i fill this field and i just see it was empty on all children type.

However, you can see on the form it could do fill : hidden link

#1245729
saisie-ajout-lot.JPG

Is the original question of this thread resolved?
https://toolset.com/forums/topic/problem-with-sort-by-date/#post-1245670
I am trying to sort by date but it doesn't work.

Please confirm it, thanks

For the new question, I have tried the URL you mentioned above:
hidden link

I can see the custom date field "Date de Livraison" is populated with value "31 décembre 2021", see screenshot:
saisie-ajout-lot.JPG

Please start a new thread for the new questions, describe detail steps to duplicate the same problem:
when a add a child i fill this field and i just see it was empty on all children type.

#1245737

My issue is resolved now. Thank you!