Skip Navigation

[Resolved] Items not appearing in view’s front end when view is ordered by a non-native dataset

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

Problem:
I created a view that lists posts ordered by a custom field added to those posts.
Not all posts appear on the View, only a few.
(Or none)

Solution:
When a View is ordered by any non-native WordPress data (data that is there anyway when you create a post) then you must ensure that this data you order by, exists for ALL posts you want to be returned.
All posts not featuring the data you use to order by, won't appear in the View!

This support ticket is created 5 years, 10 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by ashiA 5 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#1191455

Hi,

I have a site with the following 3 custom post types - Books, Online Courses & Personalities. All of these can be categorised with the default 'category' filter.

I have created views to show (a) books linked to a category (b) online courses linked to a category and (c) Personalities linked to a category. While the first 2 work fine, the personality view shows 'no items found' -- even when there are clearly items in the personality.

The views are identical (with the exception of the custom post type that it display), and were created by duplicating the views. When I go to a specific personality, that personality displays properly (so it is not an access issue, and access has not been used on any of the custom post types). Additionally, if I click on the category link displayed on the personality, it goes to the proper category archive (showing that the personality content is created, is visible and is linked to the category correctly).

In fact, there is also a category archive view that I have, which has a drop-down filter for custom post types (I have done a workaround to make this work, by having a select field in each custom post type that is the same as the custom post type name). Only books and online courses show up here. It is important to note, that this view was working perfectly fine, and all 3 custom post types were showing up. However, after enabling pagination on this view, and move around a few pages, personalities displayed from the view and is no longer showing up in any views that I create to display a list of personalities.

#1191456

Do you have a link where I can see this?

It seems something related to the pagination, as you outline.
Eventually, I can spot it by looking at it as well in the backend, if possible.

#1191476

I will look deeper into this on Tuesday, but for now, I saw you order those views by non-standard fields (such as Ranking Criteria.
Note that posts must have values in the fields you order by - as otherwise, the view would return empty.

Do all posts feature that field value?

Also, all posts must feature Categories the same as the current archive page AND Tags the same as the current archive page

is this the case?

I will make more tests myself as soon I am back on shift Tuesday

#1191477

Hi Beda,

Thanks a lot for the prompt response on a weekend. I was using a sorting on 'ranking criteria' which was not a field that was present in the personality type. On changing the sort criteria, the information has started to show up.

I am keeping this ticket open for now, as I do further testing. Will let you know if it gets resolved.

#1192364

Yes, that's what I suspected.

It is expected as in a Query that orders by some data, that data must be present.
If it's not present the resulting list of items that have no such data will not appear (it is excluded, as there is nothing to order by)

You should theoretically be able to solve this by adding the value to each post - for example, you can make the field required if it's a Types field, and with that you grant its existence.

Unfortunately, there is no way to avoid this when you query by that data, means if you use a certain data set to order then that data must exist for all the posts you expect to be returned.

#1192736

My issue is resolved now. Thank you!