[Waiting for user feedback] Ordering results by Date field, need show posts that have this field empty too

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 3 replies, has 3 voices.

Last updated by Minesh 6 days, 13 hours ago.

Assigned support staff: Minesh.

Author
Posts
#1394877

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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

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.