Skip Navigation

[Resolved] Ordering results by Date field, need show posts that have this field empty too

This support ticket is created 4 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 3 voices.

Last updated by Minesh 4 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1394877
Screen Shot 2019-11-28 at 18.17.21.png
Screen Shot 2019-11-28 at 18.15.14.png

I am trying to:
Get posts to appear in a results list, where the user has forgotton to enter the date field.

Link to a page where the issue can be seen:
Need to be logged in, but hidden link

I expected to see:
The posts that are missing the date field to be dumped to the bottom of the list by default (or the top possibly)

Instead, I got:
They just don't appear in the list. The list is being ordered 'by date field ascending' - it seems weird that it would just ignore these posts.

#1395107

Hello,

Toolset Views plugin is using WordPress PHP class WP_Query to query posts.
This is a limitation of class WP_Query, see wordpress document:
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
‘meta_value‘ – Note that a ‘meta_key=keyname‘ must also be present in the query

So if you are order the result by a custom date field, all posts should setup custom date field values, or they won't present in Views result.

In your case, you might consider setup another post view, filter by the "date field" is empty, for example:
https://toolset.com/forums/topic/view-query-exclude-posts-with-a-parent/

and display above post view under the your original view.

#1397803
Screen Shot 2019-12-02 at 14.59.22.png

Thanks for your reply! I think it's a good idea - however, I'm a little confused about the useage of the PHP block you referenced from the other post.

I've made a new view, which would ideally show all the post results that don't have the date field filled in - however, using the Toolset interface, what is the correct setting to show a date field that has been left blank?

I've tried a few combinations of STRING with the value set to '0' and others, but none of them seem to yield the desired effect.

Best wishes

#1398677

Minesh
Supporter

Languages: English (English )

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

Luo is on vacation. This is Minesh here and I'll take care of this ticket in Luo's absence. Hope this is OK.

Do you mean that you have a date custom filed and you want to display the posts where the date field is empty?

If yes:
can you please share problem URL where you added the view as well as access details and for what field I need to look at?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.